Hello,
I have a question regarding the error handling in the peak-linux-driver with char devices:
The pcan-API defines certain error codes of length 2 bytes. However, the user manual states that:
"Depending on the kind of error detailed CAN_ERR_... information is
set in the DATA[3] field of the same structure."
Since DATA is an array of type BYTE this structure can however never reach the higher error codes. So if I would just be checking for the DATA[3] byte, I'd get a CAN_ERR_OK if there were a CAN_ERR_RESOURCE for example.
Is there a second byte assigned to the error codes or are those higher-level error codes not reachable in the linux driver?
Error codes in linux driver
Re: Error codes in linux driver
Hi,
you can use the whole 4 bytes of a status message to build an error information:
Data[0] Data[1] Data[2] Data[3]
For the standard CAN errors, the last byte (Data[3]) will be enough (see Busheavy, BusOff etc).
Those >8 bit errors will not be part of a status message, but will be returned by the function you have called as return value.
regards
Michael
you can use the whole 4 bytes of a status message to build an error information:
Data[0] Data[1] Data[2] Data[3]
For the standard CAN errors, the last byte (Data[3]) will be enough (see Busheavy, BusOff etc).
Those >8 bit errors will not be part of a status message, but will be returned by the function you have called as return value.
regards
Michael
Re: Error codes in linux driver
Hi, thank you for the quick answer.
So I check the return value of LINUX_CAN_Read_Timeout() against the error codes? So is the error code returned in the CAN message redundant to that return value or will only those >8 bit errors be returned?
Cheers
Felix
So I check the return value of LINUX_CAN_Read_Timeout() against the error codes? So is the error code returned in the CAN message redundant to that return value or will only those >8 bit errors be returned?
Cheers
Felix
Re: Error codes in linux driver
Hi,
please don´t mix up status messages with return values of the API. A status messages will be received similar to a real CAN message with the CAN_Read() function, in which the databytes will contain some errorcodes, which are relevant for the CAN system (error messages related to the CAN-Controller error counter or bus status). This will be helpfull to have an exact timing when such an error occured.
All other errors, like "handle errors" etc, will only be returned by an API call, and will never be in a status message.
regards
Michael
please don´t mix up status messages with return values of the API. A status messages will be received similar to a real CAN message with the CAN_Read() function, in which the databytes will contain some errorcodes, which are relevant for the CAN system (error messages related to the CAN-Controller error counter or bus status). This will be helpfull to have an exact timing when such an error occured.
All other errors, like "handle errors" etc, will only be returned by an API call, and will never be in a status message.
regards
Michael