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
Is it possible to know if the ECU is powered on/off in a PCAN basic API
Re: Is it possible to know if the ECU is powered on/off in a PCAN basic API
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.
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
Keneth
Re: Is it possible to know if the ECU is powered on/off in a PCAN basic API
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?
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?
Re: Is it possible to know if the ECU is powered on/off in a PCAN basic API
Hello,
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.
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.
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
Keneth