Linux program to receive hexadecimal values

This forum covers PCAN-Linux and Linux development issues concerning our products

Linux program to receive hexadecimal values

Postby alextreme » Tue 23. Aug 2011, 09:53

Hi,
I have a PEAK CAN/USB interface, I used PCAN-View in Windows (1 Mb/s) to receive some DATA from my CAN interface and it works. I can receive some hexadecimal value.
Now I would like receive the same value using Linux, I have tried "receivetest" present in the CD but I have only this result:


root@FHEEL:/home/aau/Desktop/test# ./receivetest -b=0x0014

receivetest Version "Release_20090203_n" (http://www.peak-system.com)
------- Copyright (C) 2004-2009 PEAK System-Technik GmbH ------
receivetest comes with ABSOLUTELY NO WARRANTY. This is free
software and you are welcome to redistribute it under certain
conditions. For details see attached COPYING file.

receivetest: device node="/dev/pcan0"
Only standard frames are accepted, init with BTR0BTR1=0x0014
receivetest: driver version = Beta____20110223_n
^Creceivetest: type = usb
Serial Number = 0xffffffff
Device Number = 0
count of reads = 0
count of writes = 0
count of errors = 1
count of irqs = 116906
last CAN status = 0x0020
last error = 0
open paths = 1
driver version = Beta____20110223_n
receivetest: finished (0).


Thanks.

Best.
alextreme
 
Posts: 8
Joined: Mon 8. Aug 2011, 09:07

Re: Linux program to receive hexadecimal values

Postby M.Maidhof » Tue 23. Aug 2011, 10:03

Hi,

you are using /dev/pcan0 which is a PCAN-PCI card, please check the output of receivetest :

receivetest: device node="/dev/pcan0"

please use:

./receivetest -f=/dev/pcan32 -b=0x0014

when you want to use PCAN-USB with 1Mbit/s.

It will always be helpfull to have the cat /proc/pcan output to see which driver version and setup you are using.

best regards

Michael
M.Maidhof
Support
Support
 
Posts: 373
Joined: Wed 22. Sep 2010, 14:00
Location: Darmstadt, Germany

Re: Linux program to receive hexadecimal values

Postby alextreme » Tue 23. Aug 2011, 13:04

M.Maidhof wrote:Hi,

you are using /dev/pcan0 which is a PCAN-PCI card, please check the output of receivetest :

receivetest: device node="/dev/pcan0"

please use:

./receivetest -f=/dev/pcan32 -b=0x0014

when you want to use PCAN-USB with 1Mbit/s.

It will always be helpfull to have the cat /proc/pcan output to see which driver version and setup you are using.

best regards

Michael

Thanks.
But in /var I don't find pcan32.

Best.
alextreme
 
Posts: 8
Joined: Mon 8. Aug 2011, 09:07

Re: Linux program to receive hexadecimal values

Postby alextreme » Tue 23. Aug 2011, 13:56

I think that in my case pcan0 is the USB:

root@FHEEL:/sbin# cat /proc/pcan

*------------ PEAK-Systems CAN interfaces (http://www.peak-system.com) -------------
*-------------------------- Beta____20110223_n (7.0.0) ---------------------
*------------- [mod] [isa] [pci] [dng] [par] [usb] [pcc] [net] --------------
*--------------------- 1 interfaces @ major 252 found -----------------------
*n -type- ndev --base-- irq --btr- --read-- --write- --irqs-- -errors- status
0 usb can0 ffffffff 000 0x0014 00000000 00000000 0000000e 00000000 0x0000


I found also:


(9*) = From kernel version 2.6 on the behaviour during assignment of the
„minor“-numbers is being changed through the kernel parameter
„CONFIG_USB_DYNAMIC_MINORS“. When „CONFIG_USB_DYNAMIC_MINORS“ is
set, the first free „minor“-number is assigned to from 0 on. Mandrake distributions uses
this configuration.


Thanks.
alextreme
 
Posts: 8
Joined: Mon 8. Aug 2011, 09:07

Re: Linux program to receive hexadecimal values

Postby alextreme » Tue 23. Aug 2011, 14:48

I solved installing in an other Linux system, but still I can't read data:
ale@ubuntu:~/Scaricati/peak-linux-driver-7.3/test$ ./receivetest -f=/dev/pcan32 -b=0x0014

receivetest Version "Release_20090203_n" (www.peak-system.com)
------- Copyright (C) 2004-2009 PEAK System-Technik GmbH ------
receivetest comes with ABSOLUTELY NO WARRANTY. This is free
software and you are welcome to redistribute it under certain
conditions. For details see attached COPYING file.

receivetest: device node="/dev/pcan32"
Only standard frames are accepted, init with BTR0BTR1=0x0014
receivetest: driver version = Release_20110728_n
^Creceivetest: type = usb
Serial Number = 0xffffffff
Device Number = 255
count of reads = 0
count of writes = 0
count of errors = 0
count of irqs = 18884
last CAN status = 0x0020
last error = 0
open paths = 1
driver version = Release_20110728_n
receivetest: finished (0).

ale@ubuntu:~/Scaricati/peak-linux-driver-7.3/test$ ./receivetest -f=/dev/pcan32 -b=0x0014

receivetest Version "Release_20090203_n" (www.peak-system.com)
------- Copyright (C) 2004-2009 PEAK System-Technik GmbH ------
receivetest comes with ABSOLUTELY NO WARRANTY. This is free
software and you are welcome to redistribute it under certain
conditions. For details see attached COPYING file.

receivetest: device node="/dev/pcan32"
Only standard frames are accepted, init with BTR0BTR1=0x0014
receivetest: driver version = Release_20110728_n
^Creceivetest: type = usb
Serial Number = 0xffffffff
Device Number = 255
count of reads = 0
count of writes = 0
count of errors = 0
count of irqs = 98017
last CAN status = 0x0020
last error = 0
open paths = 1
driver version = Release_20110728_n
receivetest: finished (0).


Thanks. Best.
alextreme
 
Posts: 8
Joined: Mon 8. Aug 2011, 09:07

Re: Linux program to receive hexadecimal values

Postby M.Maidhof » Wed 24. Aug 2011, 12:06

Hi,

you have builded the driver for netdev (see can0 in cat /proc/pcan), but you want to use the chardev tools. This will not work. Please build the driver again with make NET=NO, to build a chardev driver. Please see the "BIG" info on our Linux website or in the pdf manual of the driver about that issue: http://www.peak-system.com/fileadmin/me ... /index.htm

best regards

Michael
M.Maidhof
Support
Support
 
Posts: 373
Joined: Wed 22. Sep 2010, 14:00
Location: Darmstadt, Germany

Re: Linux program to receive hexadecimal values

Postby alextreme » Wed 24. Aug 2011, 13:38

Thanks. I changed the driver but using b=0x0014 I have this:

ale@ubuntu:~/Scrivania/peak-linux-driver-7.3/test$ cat /proc/pcan

*------------ PEAK-Systems CAN interfaces (http://www.peak-system.com) -------------
*-------------------------- Release_20110728_n (7.3.0) ----------------------
*---------------- [mod] [isa] [pci] [dng] [par] [usb] [pcc] -----------------
*--------------------- 1 interfaces @ major 251 found -----------------------
*n -type- ndev --base-- irq --btr- --read-- --write- --irqs-- -errors- status
32 usb -NA- ffffffff 255 0x001c 00000000 00000000 00000000 00000000 0x0000

ale@ubuntu:~/Scrivania/peak-linux-driver-7.3/test$ cat /proc/pcan

*------------ PEAK-Systems CAN interfaces (http://www.peak-system.com) -------------
*-------------------------- Release_20110728_n (7.3.0) ----------------------
*---------------- [mod] [isa] [pci] [dng] [par] [usb] [pcc] -----------------
*--------------------- 1 interfaces @ major 251 found -----------------------
*n -type- ndev --base-- irq --btr- --read-- --write- --irqs-- -errors- status
32 usb -NA- ffffffff 255 0x001c 00000000 00000000 00000000 00000000 0x0000

ale@ubuntu:~/Scrivania/peak-linux-driver-7.3/test$ ./receivetest -f=/dev/pcan32 -b=0x0014

receivetest Version "Release_20090203_n" (http://www.peak-system.com)
------- Copyright (C) 2004-2009 PEAK System-Technik GmbH ------
receivetest comes with ABSOLUTELY NO WARRANTY. This is free
software and you are welcome to redistribute it under certain
conditions. For details see attached COPYING file.

receivetest: device node="/dev/pcan32"
Only standard frames are accepted, init with BTR0BTR1=0x0014
receivetest: driver version = Release_20110728_n
^Creceivetest: type = usb
Serial Number = 0xffffffff
Device Number = 255
count of reads = 0
count of writes = 0
count of errors = 0
count of irqs = 38022
last CAN status = 0x0020
last error = 0
open paths = 1
driver version = Release_20110728_n
receivetest: finished (0).


I found that changing b to b=0x0013 I have this result:
ale@ubuntu:~/Scrivania/peak-linux-driver-7.3/test$ ./receivetest -f=/dev/pcan32 -b=0x0013

receivetest Version "Release_20090203_n" (http://www.peak-system.com)
------- Copyright (C) 2004-2009 PEAK System-Technik GmbH ------
receivetest comes with ABSOLUTELY NO WARRANTY. This is free
software and you are welcome to redistribute it under certain
conditions. For details see attached COPYING file.

receivetest: device node="/dev/pcan32"
Only standard frames are accepted, init with BTR0BTR1=0x0013
receivetest: driver version = Release_20110728_n
537983.242 receivetest: m s 0x00000000 4 00 00 00 08
receivetest: pending CAN status 0x002c read.
539031.818 receivetest: m s 0x00000000 4 00 00 00 08
receivetest: pending CAN status 0x0028 read.
540080.394 receivetest: m s 0x00000000 4 00 00 00 08
receivetest: pending CAN status 0x0028 read.
541128.970 receivetest: m s 0x00000000 4 00 00 00 08
receivetest: pending CAN status 0x0028 read.
542177.546 receivetest: m s 0x00000000 4 00 00 00 08
receivetest: pending CAN status 0x0028 read.
543226.122 receivetest: m s 0x00000000 4 00 00 00 08
receivetest: pending CAN status 0x0028 read.
^Creceivetest: type = usb
Serial Number = 0xffffffff
Device Number = 255
count of reads = 14
count of writes = 0
count of errors = 14
count of irqs = 38604
last CAN status = 0x0020
last error = 0
open paths = 1
driver version = Release_20110728_n
receivetest: finished (0).


I don't know what to do. :cry: Using PCAN-View the system read the values without problem.

Thanks.
alextreme
 
Posts: 8
Joined: Mon 8. Aug 2011, 09:07

Re: Linux program to receive hexadecimal values

Postby M.Maidhof » Thu 25. Aug 2011, 10:33

Hi,

do you know what -b=0x0013 means? This is a baudrate of 1142kbit/s.....

That is why you will receive the status messages (busheavy) from the module, because you are using a wrong and even for CAN undefined baudrate >1Mbit/s.

Sorry, but the way you will solve that problem is not the right way...

Please tell me what kind of CAN frames you have on the CAN bus? Do you use standard or extended frames?

regards

Michael
M.Maidhof
Support
Support
 
Posts: 373
Joined: Wed 22. Sep 2010, 14:00
Location: Darmstadt, Germany

Re: Linux program to receive hexadecimal values

Postby alextreme » Fri 26. Aug 2011, 10:30

Hi,
I was thinking that b=0x0013 was a baudrate > of 1 Mb/s, I just posted that result.
I am using standard frame and using PCAN-VIEW I have not problem this is a trace file of PCAN-VIEW:
;$FILEVERSION=1.1
;$STARTTIME=40781.4352321412
;
; C:\Users\Maurizio\Desktop\Test.trc
;
; Start time: 26/08/2011 10:26:44.057.x
;
; Message Number
; | Time Offset (ms)
; | | Type
; | | | ID (hex)
; | | | | Data Length Code
; | | | | | Data Bytes (hex) ...
; | | | | | |
;---+-- ----+---- --+-- ----+--- + -+ -- -- -- -- -- -- --
1) 0.0 Rx 15555555 8 55 55 55 55 55 55 55 55
2) 0.1 Rx 15555555 8 55 55 55 55 55 55 55 55
3) 0.3 Rx 15555555 8 55 55 55 55 55 55 55 55
4) 0.4 Rx 15555555 8 55 55 55 55 55 55 55 55
5) 0.5 Rx 15555555 8 55 55 55 55 55 55 55 55
6) 0.6 Rx 15555555 8 55 55 55 55 55 55 55 55
7) 0.8 Rx 15555555 8 55 55 55 55 55 55 55 55
8) 0.9 Rx 15555555 8 55 55 55 55 55 55 55 55
9) 1.0 Rx 15555555 8 55 55 55 55 55 55 55 55
10) 1.2 Rx 15555555 8 55 55 55 55 55 55 55 55
11) 1.3 Rx 15555555 8 55 55 55 55 55 55 55 55


Thanks.

Best.
alextreme
 
Posts: 8
Joined: Mon 8. Aug 2011, 09:07

Re: Linux program to receive hexadecimal values

Postby M.Maidhof » Fri 26. Aug 2011, 12:49

Hi,

no, this trace shows extended frames... :D

set -e option in receivetest to solve your problem.

regards

Michael
M.Maidhof
Support
Support
 
Posts: 373
Joined: Wed 22. Sep 2010, 14:00
Location: Darmstadt, Germany

Next

Return to Linux