Is it possible to know if the ECU is powered on/off in a PCAN basic API

The free CAN Software API (Application Programming Interface) for Windows®
Post Reply
ddw0127
Posts: 4
Joined: Wed 11. May 2022, 03:00

Is it possible to know if the ECU is powered on/off in a PCAN basic API

Post by ddw0127 » Wed 11. May 2022, 03:13

Hello, I am a first-time user of PCAN equipment.

I am currently working on checking the data of the ECU using a PCAN-USB pro device, and I wonder if it can be detected with PCAN basic when the power of the ECU is cut off.

CAN_GetStatus could only be checked when the physical connection of the USB connected to the PC was disconnected.

If it can't be detected by the PCAN basic api, I'd like to know about other ways to check.

Thank you & Best regards

K.Wagner
Software Development
Software Development
Posts: 1082
Joined: Wed 22. Sep 2010, 13:36

Re: Is it possible to know if the ECU is powered on/off in a PCAN basic API

Post by K.Wagner » Wed 11. May 2022, 08:17

Hello,

There are two ways for doing this, a passive and an active way:

Passive way:
ECUs normally communicate any information periodically, so you can just listen to the CAN bus with your application and look for those periodic messages. If those are not read, then ECU is not there. Check the specificaiton of your ECU to get this information.

Active way:
Depending on the protocol used (raw CAN, J1939, ISO-TP, etc.) there are mechanisims to request information by sending specific frames. Just send that frame periodically. If at any time you stop receiving the specific answer (message acknowledge/ no bus error, but expected frame not received), or if after sending the request your PCAN device goes in any bus error (BUS_HEAVY, BUS_LIGHT, etc.), then the ECU is not available.
Best regards,
Keneth

ddw0127
Posts: 4
Joined: Wed 11. May 2022, 03:00

Re: Is it possible to know if the ECU is powered on/off in a PCAN basic API

Post by ddw0127 » Tue 7. Jun 2022, 10:17

I'm solving the problem through your answer, but I've found a problem.
When the USB port of the PCAN-USB pro device is removed, PCANBasic.Write operation returns PCAN_ERROR_OK.

I was expecting PCAN_ERROR_BUSOFF to be returned when I physically disconnect the port, am I missing something?

K.Wagner
Software Development
Software Development
Posts: 1082
Joined: Wed 22. Sep 2010, 13:36

Re: Is it possible to know if the ECU is powered on/off in a PCAN basic API

Post by K.Wagner » Tue 7. Jun 2022, 11:04

Hello,
ddw0127 wrote:
Tue 7. Jun 2022, 10:17
was expecting PCAN_ERROR_BUSOFF to be returned when I physically disconnect the port, am I missing something?
note that a PCAN-Basic connection uses a CAN net to attach to a hardware. This net is used for reading and writing. When you first connect a channel and then you remove it from the USB port (or you deactivate the USB port), then the net attached to it goes "internal" (resources are kept initialized, but no physical communication is done). Since the API first writes to a queue, and the content of the queue is written to that net, CAN_Write returns with an OK.
ddw0127 wrote:
Tue 7. Jun 2022, 10:17
I was expecting PCAN_ERROR_BUSOFF to be returned when I physically disconnect the port, am I missing something?
The error PCAN_ERROR_BUSOFF denotes a physical problem reported from a device. Since, in your case, there is no device attached, then this error cannot occur.

If you want to know if the device represented by a connected PCAN-Basic Channel is valid (whether it is attached to the PC), you need to use the function CAN_GetStatus. If the device is absent (net is internal), you will received the error PCAN_ERROR_ILLHW (0x1400) indicating that an invalid hardware identifier is currently detected.
Best regards,
Keneth

Post Reply