LINUX_CAN_Statistics and TPDIAG.wErrorFlag

USB to CAN Interface
jyjeong
Posts: 5
Joined: Tue 19. Sep 2023, 08:43

LINUX_CAN_Statistics and TPDIAG.wErrorFlag

Post by jyjeong » Tue 19. Sep 2023, 08:56

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. :D :)

User avatar
PEAK-Support
Sales & Support
Sales & Support
Posts: 1646
Joined: Fri 10. Sep 2010, 19:34

Re: LINUX_CAN_Statistics and TPDIAG.wErrorFlag

Post by PEAK-Support » Tue 19. Sep 2023, 09:04

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.
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------

User avatar
PEAK-Support
Sales & Support
Sales & Support
Posts: 1646
Joined: Fri 10. Sep 2010, 19:34

Re: LINUX_CAN_Statistics and TPDIAG.wErrorFlag

Post by PEAK-Support » Tue 19. Sep 2023, 09:31

!Thank you for the information!

Could you please post the result of

Code: Select all

cat /proc/pcan
so that we know which Driver version you exact use
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------

jyjeong
Posts: 5
Joined: Tue 19. Sep 2023, 08:43

Re: LINUX_CAN_Statistics and TPDIAG.wErrorFlag

Post by jyjeong » Tue 19. Sep 2023, 09:45

This is result of 'cat /proc/pcan'.
Attachments
Screenshot from 2023-09-19 15-43-15.png
Screenshot from 2023-09-19 15-43-15.png (24.87 KiB) Viewed 4389 times

User avatar
PEAK-Support
Sales & Support
Sales & Support
Posts: 1646
Joined: Fri 10. Sep 2010, 19:34

Re: LINUX_CAN_Statistics and TPDIAG.wErrorFlag

Post by PEAK-Support » Tue 19. Sep 2023, 12:23

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.
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------

jyjeong
Posts: 5
Joined: Tue 19. Sep 2023, 08:43

Re: LINUX_CAN_Statistics and TPDIAG.wErrorFlag

Post by jyjeong » Wed 20. Sep 2023, 01:55

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?
Attachments
dmesg.png
dmesg.png (75.12 KiB) Viewed 4361 times
0x0002.png
0x0002.png (24.42 KiB) Viewed 4361 times

User avatar
PEAK-Support
Sales & Support
Sales & Support
Posts: 1646
Joined: Fri 10. Sep 2010, 19:34

Re: LINUX_CAN_Statistics and TPDIAG.wErrorFlag

Post by PEAK-Support » Wed 20. Sep 2023, 08:26

As i wrote in my last post - looks like your application do not read the queues in time.
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------

jyjeong
Posts: 5
Joined: Tue 19. Sep 2023, 08:43

Re: LINUX_CAN_Statistics and TPDIAG.wErrorFlag

Post by jyjeong » Wed 20. Sep 2023, 09:55

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..

User avatar
PEAK-Support
Sales & Support
Sales & Support
Posts: 1646
Joined: Fri 10. Sep 2010, 19:34

Re: LINUX_CAN_Statistics and TPDIAG.wErrorFlag

Post by PEAK-Support » Wed 20. Sep 2023, 10:02

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.
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------

jyjeong
Posts: 5
Joined: Tue 19. Sep 2023, 08:43

Re: LINUX_CAN_Statistics and TPDIAG.wErrorFlag

Post by jyjeong » Thu 21. Sep 2023, 01:32

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'.

Post Reply