Trouble with PCAN-BASIC

This forum covers PCAN-Linux and Linux development issues concerning our products
Post Reply
lammer18
Posts: 3
Joined: Wed 23. May 2018, 18:56

Trouble with PCAN-BASIC

Post by lammer18 » Thu 24. May 2018, 20:13

Hello, I am working with a PEAK PCAN-PCIe FD on Linux and having trouble with both the PCAN-Basic tests and the peak driver test. Heres my method and outputs from a few commands

For Drivers:
sudo rmmod pcan
make clean
make NET=NO
sudo make install
sudo modprobe pcan

Output from

Code: Select all

receivetest -f=/dev/pcan0 -b=CAN_BAUD_1M

Code: Select all

receivetest: device node="/dev/pcan0"
Only standard frames are accepted, init with BTR0BTR1=0x00ca
receivetest: driver version = Release_20171027_n
2471409870.480 receivetest: m s 0x00000008 4 00 00 00 80 
receivetest: pending CAN status 0x00a1 read.
hello.txt:

Code: Select all

m s 0x0c4 2 0x0a 0x1d
Output from

Code: Select all

$ cat /proc/pcan

Code: Select all

*n -type- -ndev- --base-- irq --btr- --read-- --write- --irqs-- -errors- status
 0  pcifd   -NA-  1d81000 016 0x004a 00000001 000001f4 00000000 00000001 0x0000
 1  pcifd   -NA-  1d82000 016 0x001c 00000000 00000000 00000000 00000000 0x0000
 2  pcifd   -NA-  1d83000 016 0x001c 00000000 00000000 00000000 00000000 0x0000
 3  pcifd   -NA-  1d84000 016 0x001c 00000000 00000000 00000000 00000000 0x0000
Output from

Code: Select all

$ dmesg | grep pcan

Code: Select all

[    1.318234] pcan: module verification failed: signature and/or required key missing - tainting kernel
[    1.318927] pcan: Release_20171027_n (le)
[    1.318928] pcan: driver config [mod] [isa] [pci] [pec] [dng] [par] [usb] [pcc] 
[    1.319163] pcan: uCAN PCI device sub-system id 14h (4 channels)
[    1.319181] pcan: uCAN PCB v3h FPGA v3.2.1 (mode 3)
[    1.319216] pcan: pci uCAN device minor 0 found
[    1.319227] pcan: pci uCAN device minor 1 found
[    1.319250] pcan: pci uCAN device minor 2 found
[    1.319297] pcan: pci uCAN device minor 3 found
[    1.319333] usbcore: registered new interface driver pcan
[    1.320031] pcan: major 244.
[    2.470272] Modules linked in: snd_hda_codec_hdmi(+) i915 drm_kms_helper drm fb_sys_fops syscopyarea sysfillrect sysimgblt ipmi_msghandler bnep rfcomm snd_hda_codec_realtek snd_hda_codec_generic input_leds snd_hda_intel snd_hda_codec x86_pkg_temp_thermal coretemp snd_hda_core kvm_intel snd_hwdep snd_pcm kvm irqbypass binfmt_misc crct10dif_pclmul snd_seq_midi crc32_pclmul snd_seq_midi_event snd_rawmidi aesni_intel snd_seq aes_x86_64 lrw gf128mul glue_helper ablk_helper cryptd snd_seq_device snd_timer pcan(OE) snd pcmcia serio_raw pcmcia_core soundcore i2c_algo_bit shpchp hci_uart btbcm btqca btintel parport_pc bluetooth ppdev 8250_fintek video i2c_hid intel_lpss_acpi intel_lpss acpi_pad lp parport mac_hid acpi_als kfifo_buf industrialio hid_generic usbhid hid e1000e ptp psmouse ahci pps_core libahci fjes
[  185.826899] usbcore: deregistering interface driver pcan
[  185.826995] pcan: removed.
[  244.237012] pcan: Release_20171027_n (le)
[  244.237014] pcan: driver config [mod] [isa] [pci] [pec] [dng] [par] [usb] [pcc] 
[  244.237111] pcan: uCAN PCI device sub-system id 14h (4 channels)
[  244.237124] pcan: uCAN PCB v3h FPGA v3.2.1 (mode 3)
[  244.237136] pcan: pci uCAN device minor 0 found
[  244.237144] pcan: pci uCAN device minor 1 found
[  244.237151] pcan: pci uCAN device minor 2 found
[  244.237159] pcan: pci uCAN device minor 3 found
[  244.237180] usbcore: registered new interface driver pcan
[  244.237315] pcan: major 244.
[  376.127485] usbcore: deregistering interface driver pcan
[  376.127593] pcan: removed.
[  460.237830] pcan: Release_20171027_n (le)
[  460.237835] pcan: driver config [mod] [isa] [pci] [pec] [dng] [par] [usb] [pcc] 
[  460.238088] pcan: uCAN PCI device sub-system id 14h (4 channels)
[  460.238118] pcan: uCAN PCB v3h FPGA v3.2.1 (mode 3)
[  460.238157] pcan: pci uCAN device minor 0 found
[  460.238185] pcan: pci uCAN device minor 1 found
[  460.238212] pcan: pci uCAN device minor 2 found
[  460.238239] pcan: pci uCAN device minor 3 found
[  460.238298] usbcore: registered new interface driver pcan
[  460.238731] pcan: major 244.
[  992.138585] usbcore: deregistering interface driver pcan
[  992.138751] pcan: removed.
[ 1244.773550] pcan: Release_20171027_n (le)
[ 1244.773553] pcan: driver config [mod] [isa] [pci] [pec] [dng] [par] [usb] [pcc] 
[ 1244.773700] pcan: uCAN PCI device sub-system id 14h (4 channels)
[ 1244.773720] pcan: uCAN PCB v3h FPGA v3.2.1 (mode 3)
[ 1244.773739] pcan: pci uCAN device minor 0 found
[ 1244.773753] pcan: pci uCAN device minor 1 found
[ 1244.773766] pcan: pci uCAN device minor 2 found
[ 1244.773779] pcan: pci uCAN device minor 3 found
[ 1244.773812] usbcore: registered new interface driver pcan
[ 1244.775213] pcan: major 244.
Output from

Code: Select all

$ uname -a

Code: Select all

Linux ralab-desktop 4.4.0-31-generic #50~14.04.1-Ubuntu SMP Wed Jul 13 01:07:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
When I run PCAN-BASIC c++ example

Code: Select all

$ ./pcanread 

Code: Select all

Initialize CAN: 512
Error 0x4000000
I assume this
PCAN_ERROR_INITIALIZE 0x4000000U
error comes from the fact there is no CAN0 bus initialized on the device. I do not know what to do at this point. I have used PCAN Windows API to successfully send and receive expected results.

Thanks!

Kyle

lammer18
Posts: 3
Joined: Wed 23. May 2018, 18:56

Re: Trouble with PCAN-BASIC

Post by lammer18 » Sun 27. May 2018, 16:15

So after still not having luck I worked on using the pcanfdtst and still no luck. I added a memcpy call on line 1105 of pcanfdtst.c to send the fields I want.

Case in point: I have PCAN API working on Windows both sending and receiving as expected and cannot get the same functionality in linux

Is there anyone that provide assistance?

Kyle

User avatar
S.Grosjean
Software Development
Software Development
Posts: 357
Joined: Wed 4. Jul 2012, 17:02

Re: Trouble with PCAN-BASIC

Post by S.Grosjean » Mon 28. May 2018, 12:00

Hi,

Can you give us the exact command line you used with pcanfdtst please?

FYI, if you want to display the CAN traffic from read from /dev/pcanpcifd0 connected to a CAN bus set to 1Mbps bitrate, you should run:

Code: Select all

$ pcanfdtst rx -b 1M /dev/pcanpcifd0
Can you give us the result of the above command?

When the above command runs, can you open a 2nd shell window and type "$ cat /proc/pcan"
Do you use the same PC/CAN bus with Windows too?

Regards,

Stéphane
— Stéphane

lammer18
Posts: 3
Joined: Wed 23. May 2018, 18:56

Re: Trouble with PCAN-BASIC

Post by lammer18 » Tue 29. May 2018, 19:19

Stephane,

The command I use with pcanfdtst is:

Code: Select all

pcanfdtst tx -b 1M -i 0x0c4 -n 10 -l 2 /dev/pcanpcifd0
also to have similar settings to the windows implementation:

Code: Select all

pcanfdtst tx -c 24M -b 1M -d 2M -i 0x0c4 -n 10 -l 2 /dev/pcanpcifd0
Result of

Code: Select all

$ pcanfdtst rx -b 1M /dev/pcanpcifd0
is blank and doesn’t display any received frames.
2nd terminal runs cat /proc/pcan and gets:

Code: Select all

*------------- PEAK-System CAN interfaces (www.peak-system.com) -------------
*------------- Release_20171027_n (8.5.1) May 29 2018 13:04:13 --------------
*------------- [mod] [isa] [pci] [pec] [dng] [par] [usb] [pcc] --------------
*--------------------- 4 interfaces @ major 244 found -----------------------
*n -type- -ndev- --base-- irq --btr- --read-- --write- --irqs-- -errors- status
 0  pcifd   -NA-  1ca1000 016 0x0014 00000000 0000000a 00000000 00000000 0x0000
 1  pcifd   -NA-  1ca2000 016 0x001c 00000000 00000000 00000000 00000000 0x0000
 2  pcifd   -NA-  1ca3000 016 0x001c 00000000 00000000 00000000 00000000 0x0000
 3  pcifd   -NA-  1ca4000 016 0x001c 00000000 00000000 00000000 00000000 0x0000
The hardware is the exact same for both windows and linux implementations.

Thanks,

Kyle

User avatar
S.Grosjean
Software Development
Software Development
Posts: 357
Joined: Wed 4. Jul 2012, 17:02

Re: Trouble with PCAN-BASIC

Post by S.Grosjean » Wed 30. May 2018, 09:32

Hello Kyle,

You have successfully written 10 frames on CAN0 (as said by the "write" column of cat /proc/pcan, in hexadecimal).

But you won't be able to "read" them from the SAME channel. You have to connect CAN0 of the board to (for example) CAN1 and type:

Code: Select all

$ pcanfdtst rx -b 1M /dev/pcanpcifd1
To have any chance to read them.

Regards,

Stéphane
— Stéphane

Post Reply