Page 1 of 2
LINUX_CAN_Statistics and TPDIAG.wErrorFlag
Posted: Tue 19. Sep 2023, 08:56
by jyjeong
I want to check PCAN-USB state.
By using libpcan.h and pcan.h, I used LINUX_CAN_Statistics function and read TPDIAG.wErrorFlag.
I kept checking the status with the print statement while using it.
I found wErrorFlag is 14 and status is 0x000e. (I checked 0x000e with cat/proc/pcan.)
What is mean 'wErrorFlag 14, status 0x000e' ?
Thank you.

Re: LINUX_CAN_Statistics and TPDIAG.wErrorFlag
Posted: Tue 19. Sep 2023, 09:04
by PEAK-Support
We need to know which Hardware you are using.
Please send the part and serial number, incl. a picture of the used device to
support@peak-system.com
We will then answer ASAP.
Re: LINUX_CAN_Statistics and TPDIAG.wErrorFlag
Posted: Tue 19. Sep 2023, 09:31
by PEAK-Support
!Thank you for the information!
Could you please post the result of
so that we know which Driver version you exact use
Re: LINUX_CAN_Statistics and TPDIAG.wErrorFlag
Posted: Tue 19. Sep 2023, 09:45
by jyjeong
This is result of 'cat /proc/pcan'.
Re: LINUX_CAN_Statistics and TPDIAG.wErrorFlag
Posted: Tue 19. Sep 2023, 12:23
by PEAK-Support
Take a look into the pcan.h file, part of the driver source. There you find the error code definition.
Code: Select all
/*
* error codes
*/
#define CAN_ERR_OK 0x0000 // no error
#define CAN_ERR_XMTFULL 0x0001 // transmit buffer full
#define CAN_ERR_OVERRUN 0x0002 // overrun in receive buffer
#define CAN_ERR_BUSLIGHT 0x0004 // bus error, errorcounter limit reached
#define CAN_ERR_BUSHEAVY 0x0008 // bus error, errorcounter limit reached
#define CAN_ERR_BUSOFF 0x0010 // bus error, 'bus off' state entered
#define CAN_ERR_QRCVEMPTY 0x0020 // receive queue is empty
#define CAN_ERR_QOVERRUN 0x0040 // receive queue overrun
#define CAN_ERR_QXMTFULL 0x0080 // transmit queue full
#define CAN_ERR_REGTEST 0x0100 // test of controller registers failed
#define CAN_ERR_NOVXD 0x0200 // Win95/98/ME only
#define CAN_ERR_RESOURCE 0x2000 // can't create resource
#define CAN_ERR_ILLPARAMTYPE 0x4000 // illegal parameter
#define CAN_ERR_ILLPARAMVAL 0x8000 // value out of range
#define CAN_ERRMASK_ILLHANDLE 0x1C00 // wrong handle, handle error
14 DEC is 0x000e HEX - it is the same Information.
The Error codes are BIT decoded (multiple Errors / Warnings / Information in one Value)
Your Error 14DEC/0x000e is a combination of these 3 Errors:
Code: Select all
#define CAN_ERR_OVERRUN 0x0002 // overrun in receive buffer
#define CAN_ERR_BUSLIGHT 0x0004 // bus error, errorcounter limit reached
#define CAN_ERR_BUSHEAVY 0x0008 // bus error, errorcounter limit reached
Looks like you have a physical problem - no termination, wrong bitrate timing, no second active CAN Node that could ACK etc.
Also the receive buffer was not written in time (always read until buffer is empty)
For LINUX, using our CharDev driver, we recommend to use the PCAN-Basic API, because it is much more comfortable and could also be used cross platform (Windows and LINUX)
See "libpcanbasic" folder.
Re: LINUX_CAN_Statistics and TPDIAG.wErrorFlag
Posted: Wed 20. Sep 2023, 01:55
by jyjeong
Thanks for answering.
Only 0x0002 was detected when the connection line was not moved.
When rxqsize is 2000, an error occurs when the data comes in for the 2700 times.
I've increased the rxqsize, but it's only late symptoms.
The result is confirmed through the 'dmesg | grep pcan' command, the upper result is before the problem, and the lower result is after the problem.
At this time, Error flag is 2.
Lowering the baud rate and increasing the rxqsize also causes the same problem, is this related to physical problems?
Re: LINUX_CAN_Statistics and TPDIAG.wErrorFlag
Posted: Wed 20. Sep 2023, 08:26
by PEAK-Support
As i wrote in my last post - looks like your application do not read the queues in time.
Re: LINUX_CAN_Statistics and TPDIAG.wErrorFlag
Posted: Wed 20. Sep 2023, 09:55
by jyjeong
I tried to increase rxqsize and LINUX_CAN_Write_Timeout, LINUX_CAN_Read_Timeout function.
And.. I also set the boat rate to 250K.
This is all I know as a way to improve overrun, can you give me a rough idea of how to get data on time?
Actually, I don't know much about CAN Communications. Sorry..
Re: LINUX_CAN_Statistics and TPDIAG.wErrorFlag
Posted: Wed 20. Sep 2023, 10:02
by PEAK-Support
have you checked our sample code ? There you see how to read the CAN data...as we do not know what exact you do we are not able to give you more tips as we did..
Best is to run the sample code - this is well tested and must work. If you still have the same problems with the sample code , you have a physical problem , as we wrote.
Re: LINUX_CAN_Statistics and TPDIAG.wErrorFlag
Posted: Thu 21. Sep 2023, 01:32
by jyjeong
Is the sample code transmitest and receivetest?
The error doesn't appear when I do transmitest using n=10, but if I do n=10, I get bus off in dmesg command.
And result of 'cat /proc/pcan' show me 'status 0x0000, errors 00000023'.