Page 1 of 1

Detect if the device goes missing?

Posted: Tue 20. Aug 2024, 10:49
by tanyabell
Hello,

I'm working with PCAN-UDS and a Peak-USB device. When I connect the device, the channel condition goes from Unavailable to Available. If I disconnect it, it goes back to Unavailable.

However, if I call PCAN_Initialize on the corresponding handle, the condition becomes Occupied. I tried physically disconnecting the device from the computer, the same problem still remains.

Is there anyway to detect when the device is disconnected?
Thanks in advance!

Re: Detect if the device goes missing?

Posted: Tue 20. Aug 2024, 11:00
by M.Heidemann
the channel remains occupied because the connection will continue working, when you connect that device again (it is "reserved" for that application). If you want to check if a channel is still physically there, you need to call CAN_GetStatus periodically. If the device is plugged out, then you will get the error PCAN_ERROR_ILLHW (0x1400 - Invalid hardware handle)

BR
Marvin

Re: Detect if the device goes missing?

Posted: Wed 28. Aug 2024, 19:57
by tanyabell
the channel remains occupied because the connection will continue working, when you connect that device again (it is "reserved" for that application). If you want to check if a channel is still physically there, you need to call CAN_GetStatus periodically. If the device is plugged out, then you will get the error PCAN_ERROR_ILLHW (0x1400 - Invalid hardware handle)

BR
Marvin
Thanks for your answer. I got it.