PhidgetException 0x34 (Device not Attached) VINT HUB0000_0

Supporting Visual Studio on Windows
Post Reply
emmanuelfc1683
Fresh meat
Posts: 2
Joined: Fri Feb 14, 2020 3:07 pm
Contact:

PhidgetException 0x34 (Device not Attached) VINT HUB0000_0

Post by emmanuelfc1683 »

I am developing with c#.net and I am having some problems when solution start, The application show:

PhidgetException 0x34 (Device not Attached) VINT HUB0000_0
This can happen for a number of common reasons. Be sure you are opening the channel before trying to use it.
If you are opening the channel, the program may not be waiting for the channel to be attached.
If possible use openWaitForAttachment. Otherwise, be sure to check the Attached property of the channel before trying to use it.


Could anyone help me please, I'm new with phidget controls.

So I show them some code that I have developed...I am using VINT HUB0000_0

Code: Select all

        private void Maincontrol_Load(object sender, EventArgs e)
        {

            TempSensor0 = new VoltageRatioInput();
            TempSensor0.Attach += TempSensor0_Attach;
            TempSensor0.Detach += TempSensor0_Detach;
            TempSensor0.Error += TempSensor0_Error;
            TempSensor0.SensorChange += TempSensor0_SensorChange;
            //Set addressing parameters
            TempSensor0.IsHubPortDevice = true;
            TempSensor0.HubPort = 0;
            TempSensor0.Channel = 0;

            LimitSwitch = new DigitalInput();
            LimitSwitch.StateChange += LimitSwitch_StateChange;
            LimitSwitch.Attach += LimitSwitch_Attach;
            LimitSwitch.Detach += LimitSwitch_Detach;
            LimitSwitch.Error += LimitSwitch_Error;
            //Set addressing parameters
            LimitSwitch.HubPort = 3;

            SolenoidValve = new DigitalOutput();
            SolenoidValve.Attach += SolenoidValve_Attach;
            SolenoidValve.Detach += SolenoidValve_Detach;
            SolenoidValve.Error += SolenoidValve_Error;
            //Set addressing parameters
            SolenoidValve.IsHubPortDevice = true;
            SolenoidValve.HubPort = 2;

            try
            {
                // Open Phidgets
                TempSensor0.Open();
                TempSensor0.SensorType = Phidget22.VoltageRatioSensorType.PN_1124;

                LimitSwitch.Open();

                SolenoidValve.Open();
                SolenoidValve.DutyCycle = 1;

            }
            catch (PhidgetException)
            {
                TempSensor0.Close();
                LimitSwitch.Close();
                SolenoidValve.Close();
                throw;
            }
        }

Thanks a lot
User avatar
mparadis
Site Admin
Posts: 660
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: PhidgetException 0x34 (Device not Attached) VINT HUB0000_0

Post by mparadis »

The line that's causing the error is probably

Code: Select all

TempSensor0.SensorType = Phidget22.VoltageRatioSensorType.PN_1124;
The problem is that you're calling this immediately after opening the device, but the device takes time to attach. You should move this line into your TempSensor0_Attach function. Likewise, you should move the SolenoidValve's duty cycle setting into SolenoidValve_Attach. This way you'll be able to guarantee the channels are already attached when these properties are set.
emmanuelfc1683
Fresh meat
Posts: 2
Joined: Fri Feb 14, 2020 3:07 pm
Contact:

Re: PhidgetException 0x34 (Device not Attached) VINT HUB0000_0

Post by emmanuelfc1683 »

You're right, I changed my code as your suggestion and I don't have any problem with the functionality.


Thanks so much
derammo
Fresh meat
Posts: 4
Joined: Thu May 14, 2020 6:46 pm
Contact:

Re: PhidgetException 0x34 (Device not Attached) VINT HUB0000_0

Post by derammo »

Addendum:

I had a related problem and google led me here. For sharing purposes, even though my root cause is different:

I was calling Open() after receiving Attached event from the Device Manager. Then I configured away immediately, assuming the device is in fact attached. However, if you use the default Open() method it is still asynchronous, even though the channel is in fact attached. This was a failure to understand the API on my part :). After Attach event, you can just Open(0) to specify infinite timeout, since the device is in fact present. In production code, I would probably use a short timeout instead of infinity and then check if the channel is operable. It would be nice if there was a return value from Open(timeout).
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 0 guests