Detect if the device goes missing?

A free API for the communication with control devices according to UDS (ISO 14229-1)
Post Reply
tanyabell
Posts: 3
Joined: Tue 20. Aug 2024, 10:41

Detect if the device goes missing?

Post by tanyabell » Tue 20. Aug 2024, 10:49

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!

M.Heidemann
Sales & Support
Sales & Support
Posts: 1083
Joined: Fri 20. Sep 2019, 13:31

Re: Detect if the device goes missing?

Post by M.Heidemann » Tue 20. Aug 2024, 11:00

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
---
Marvin Heidemann
PEAK-Support Team

tanyabell
Posts: 3
Joined: Tue 20. Aug 2024, 10:41

Re: Detect if the device goes missing?

Post by tanyabell » Wed 28. Aug 2024, 19:57

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.

Post Reply