Hello All. Below is a exception that I have been getting and the code that throws it. I can't seem to figure it out. I was hoping that someone could shed some light on it or let me know how to handle it. I have tried catching it but it still closes the program. Thanks
Exception:
An unhandled exception of type 'Phidgets.PhidgetException' occurred in Phidget21.NET.dll
Additional information: PhidgetException 9 (Value is Unknown (State not yet received from device, or not yet set by user)
Program Code:
Public Class ReservoirCalibration
Dim WithEvents Bridge1 As Phidgets.Bridge
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
Private Sub ReservoirCalibration_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
Bridge1 = New Phidgets.Bridge
Bridge1.open()
Timer1.Start()
Bridge1.bridges(0).Enabled = True
Catch outofrange As System.ArgumentOutOfRangeException
Catch ex As Phidgets.PhidgetException
MessageBox.Show(ex.ToString())
End Try
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
LoadCell1Raw.Text = Bridge1.bridges(0).BridgeValue.ToString
End Sub
End Class
This is happening because you are setting the Enabled property before the bridge has enough time to set up communication with the device.
After you call open() you should call waitForAttachment(). This is a blocking call that returns once the device hardware has been initialized by the drivers in the library and is ready to receive commands.
As just written in a new Thread, I've the exact same problem often when closing the Bridge.
I still do not understand why.
I use 3 forms in my VB2008 application, Bridge works fine.
Only problem is that often - while doing a Me.Close + Bridge.Close() + Newform.Show, the application freezes (and stop responding) exactly on the Bridge.Close() row.
I still cannot figure out where's the problem and why it does that.
This generally happen if you have the bridge data event handler set up, and then close the bridge in a form closing event. This will cause a deadlock. You need to deregister the event 1st, then call Application.DoEvents(), then close the bridge.
Hi, just an update about my application often freezing while losing focus on a Form, locking on Bridge.Close() row :
after using Phidget21.NET.dll in place of Phidget21.NET1.1.dll, all my problems went away.
Tested on my W10 pc, using Visula Basic 2008, Visual Basic 2010 and eVisual Studio 2017 : no problems at all