No incoming messages with PCANBasic

This forum covers PCAN-Linux and Linux development issues concerning our products
Post Reply
HPetruck
Posts: 10
Joined: Fri 10. Jun 2016, 10:57

No incoming messages with PCANBasic

Post by HPetruck » Tue 14. Jun 2016, 11:15

Hello,

currently I am porting a Windows application to Ubuntu, with both Operating Systems I am using the PCAN Basic API and the PEAK USB CAN Adapter. But under Linux I am not receiving any messages, the same method calls work fine in Windows.

The tranmitest and receivetest from the linux driver yield the following output of cat /proc/pcan:

Code: Select all

*------------- PEAK-System CAN interfaces (www.peak-system.com) -------------
*------------- Release_20150729_n (7.15.2) Jun 14 2016 08:44:35 --------------
*------------- [mod] [isa] [pci] [pec] [dng] [par] [usb] [pcc] --------------
*--------------------- 1 interfaces @ major 249 found -----------------------
*n -type- -ndev- --base-- irq --btr- --read-- --write- --irqs-- -errors- status
32    usb   -NA- ffffffff 000 0x001c 0000f965 0001a25c 0001c2e4 0000a897 0x0000
The pcanwrite test program from the API seems to work fine:

Code: Select all

*------------- PEAK-System CAN interfaces (www.peak-system.com) -------------
*------------- Release_20150729_n (7.15.2) Jun 14 2016 08:44:35 --------------
*------------- [mod] [isa] [pci] [pec] [dng] [par] [usb] [pcc] --------------
*--------------------- 1 interfaces @ major 249 found -----------------------
*n -type- -ndev- --base-- irq --btr- --read-- --write- --irqs-- -errors- status
32    usb   -NA- ffffffff 000 0x001c 00000000 0000a75c 000002f7 00000000 0x0000
The pcanread test program does not read any messages:

Code: Select all

*------------- PEAK-System CAN interfaces (www.peak-system.com) -------------
*------------- Release_20150729_n (7.15.2) Jun 14 2016 08:44:35 --------------
*------------- [mod] [isa] [pci] [pec] [dng] [par] [usb] [pcc] --------------
*--------------------- 1 interfaces @ major 249 found -----------------------
*n -type- -ndev- --base-- irq --btr- --read-- --write- --irqs-- -errors- status
32    usb   -NA- ffffffff 000 0x001c 00000000 00000000 00000014 00000000 0x0000
Now at the first application start (the application basically sends one message to a robot and waits for the answer at the start) I receive one confusing message with the message type 0x60 and the data bytes: 0x0 0x0 0x0 0x8 0x0 0x0 0x0 0x0. The output of cat /proc/pcan is:

Code: Select all

*------------- PEAK-System CAN interfaces (www.peak-system.com) -------------
*------------- Release_20150729_n (7.15.2) Jun 14 2016 08:44:35 --------------
*------------- [mod] [isa] [pci] [pec] [dng] [par] [usb] [pcc] --------------
*--------------------- 1 interfaces @ major 249 found -----------------------
*n -type- -ndev- --base-- irq --btr- --read-- --write- --irqs-- -errors- status
32    usb   -NA- ffffffff 000 0x001c 00000001 00000001 00000038 00000000 0x0000
At all further runs no messages are received, even after minutes of periodically calling CAN_Read:

Code: Select all

*------------- PEAK-System CAN interfaces (www.peak-system.com) -------------
*------------- Release_20150729_n (7.15.2) Jun 14 2016 08:44:35 --------------
*------------- [mod] [isa] [pci] [pec] [dng] [par] [usb] [pcc] --------------
*--------------------- 1 interfaces @ major 249 found -----------------------
*n -type- -ndev- --base-- irq --btr- --read-- --write- --irqs-- -errors- status
32    usb   -NA- ffffffff 000 0x001c 00000000 00000001 0000003c 00000000 0x0000
The same code works find with Windows, the robot is plugged it with the same CAN Cable terminated at both ends. With windows I receive the correct answer of the robot at the first call of CAN_Read.

Regards
Henning

M.Maidhof
Support
Support
Posts: 1753
Joined: Wed 22. Sep 2010, 14:00

Re: No incoming messages with PCANBasic

Post by M.Maidhof » Tue 14. Jun 2016, 13:50

Hi,

the returned message looks like a status message, can you please check the MSGTYPE of that message before processing the message as a real CAN message. Sure you intialize with normal CAN mode and NOT the "listen only" mode?

Please note that it will be impossible to help you with your application, without seeing the code you are using. Please also check the correct installation of the PCANBasic API.

As a test, please use the libpcan applications receivetest and transmittest, to see if it is an API based problem.

regards

Michael

HPetruck
Posts: 10
Joined: Fri 10. Jun 2016, 10:57

Re: No incoming messages with PCANBasic

Post by HPetruck » Tue 14. Jun 2016, 17:20

The message was sent to the robot with the message type standard. The PCAN Basis test tool pcanread works fine, it reads the robot's answers to the messages sent by transmitest. The test tool pcanwrite always returns PCAN_ERROR_OK from the function call CAN_Write, but I do not receive any answers with receivetest. How would I initialize the interface in "listen only" mode? What parameters are neccesary for that?

Regards
Henning

M.Maidhof
Support
Support
Posts: 1753
Joined: Wed 22. Sep 2010, 14:00

Re: No incoming messages with PCANBasic

Post by M.Maidhof » Wed 15. Jun 2016, 12:47

Hi,

please note that with the chardev driver, only one application could be active to call CAN_Read() otherwise the other application will not read anything. As written above, please post your code.

Listen Only will be set by SetValue, see help file for PCANBasic under Windows for more Details.

HPetruck
Posts: 10
Joined: Fri 10. Jun 2016, 10:57

Re: No incoming messages with PCANBasic

Post by HPetruck » Thu 16. Jun 2016, 11:32

Solved,

from another example code I used the define:

Code: Select all

#define DWORD  unsigned long
Replaced it with

Code: Select all

#define DWORD  unsigned int
and now everything works.

Regards
Henning

Post Reply