CANopen not working with Codesys [Solved]
Posted: 20 Apr 2021, 15:18
IMPORTANT: I think, I found a suitable way to do it, I will post my workflow in the following days!
We did everything exactly as described in the tutorial, however CANopen in Codesys won’t run on our RevPi Connect / Con CAN Configuration (and it seems we’re not the only one having this kind of trouble, see here and here ).
We followed the official tutorial as well as the tutorial for the new package from Mr. Amar.
We are using
Our Workflow was the following:
1.) We checked our RevPi Version in PuTTy using “uname -a”
The command “sudo apt-get update” yields:
2.) configured Connect and Con Can module to Right side in Codesys IDE 3.) configure the script for setting baud rate:
4.) Enabled RevPi Con CAN using following command
Important: Unit now, the command “ip -det -statistics link show can0” yields zero errors:
5.) Download the Codesys Program (without starting it)
6.) Rebooted Target using the "Tools --> Update Raspberry Pi" Tab in Codesys
Note: until now, the Command “piTest -d” yields
7.) After I reboot the target, nothing works anymore on the CAN-Bus:
And the command “ip -det -statistics link show can0” yield an error-passive state for my device.
Having performed all the steps exactly as described in the official tutorials, I have not the slightest idea what to do. Any help is much appreciated!
Note: For some reason, Codesys and Con CAN seem to work, if the "CAN-Bus" and the "CANopen Manager" was NOT inserted in the Codesys Project (All "circles" are green in online mode).
We did everything exactly as described in the tutorial, however CANopen in Codesys won’t run on our RevPi Connect / Con CAN Configuration (and it seems we’re not the only one having this kind of trouble, see here and here ).
We followed the official tutorial as well as the tutorial for the new package from Mr. Amar.
We are using
- RevPi Connect Plus
- RevPi Con Can
- Connect Bridge
- Codesys Development System V. 3.5 SP16 Patch 4
- CODESYS Control for Raspberry PI V 4.0.1.0
- Revolution Pi Bridge V1.0.1.99 Package in Codesys
Our Workflow was the following:
1.) We checked our RevPi Version in PuTTy using “uname -a”
Code: Select all
pi@fftmantonsteuerung:~ $ uname -a
Linux fftmantonsteuerung 4.19.95-rt38-v7 #1 SMP PREEMPT RT Fri, 26 Mar 2021 13:57:12 +0100 armv7l GNU/Linux
Code: Select all
pi@fftmantonsteuerung:~ $ sudo apt-get update
OK:1 http://archive.raspberrypi.org/debian stretch InRelease
Holen:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease [15,0 kB]
OK:3 http://repository.teamviewer.com/deb stable InRelease
OK:4 http://packages.revolutionpi.de stretch InRelease
OK:5 http://packages.revolutionpi.de stretch-backports InRelease
Es wurden 15,0 kB in 2 s geholt (5.162 B/s).
Paketlisten werden gelesen... Fertig
2.) configured Connect and Con Can module to Right side in Codesys IDE 3.) configure the script for setting baud rate:
Code: Select all
sudo nano /var/opt/codesys/rts_set_baud.sh
#!/bin/sh
BITRATE=`expr $2 \\* 1000`
ifconfig $1 down
echo ip link set $1 type can bitrate $BITRATE
ip link set $1 type can bitrate $BITRATE
ifconfig $1 up
sudo chmod +x /var/opt/codesys/rts_set_baud.sh
4.) Enabled RevPi Con CAN using following command
Code: Select all
pi@fftmantonsteuerung:~ $ sudo revpi-config enable revpi-con-can
* Failed to apply overlay '0_revpi-con-can' (kernel)
1
Important: Unit now, the command “ip -det -statistics link show can0” yields zero errors:
Code: Select all
pi@fftmantonsteuerung:~ $ ip -det -statistics link show can0
5: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10
link/can promiscuity 0
can state STOPPED (berr-counter tx 0 rx 0) restart-ms 0
hi3110: tseg1 2..16 tseg2 2..8 sjw 1..4 brp 1..64 brp-inc 1
clock 16000000
re-started bus-errors arbit-lost error-warn error-pass bus-off
0 0 0 0 0 0 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
RX: bytes packets errors dropped overrun mcast
0 0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
Note: until now, the Command “piTest -d” yields
Code: Select all
pi@fftmantonsteuerung:~ $ piTest -d
Found 2 devices:
Address: 0 module type: 105 (0x69) RevPi Connect V1.0
Module is present
input offset: 0 length: 6
output offset: 6 length: 5
Address: 32 module type: 109 (0x6d) RevPi CON CAN V0.0
Module is present
input offset: 0 length: 0
output offset: 0 length: 0
Code: Select all
pi@fftmantonsteuerung:~ $ ip -det -statistics link show can0
5: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
link/can promiscuity 0
can state ERROR-PASSIVE (berr-counter tx 128 rx 0) restart-ms 0
bitrate 1000000 sample-point 0.750
tq 62 prop-seg 5 phase-seg1 6 phase-seg2 4 sjw 1
hi3110: tseg1 2..16 tseg2 2..8 sjw 1..4 brp 1..64 brp-inc 1
clock 16000000
re-started bus-errors arbit-lost error-warn error-pass bus-off
0 0 0 1 1 0 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
RX: bytes packets errors dropped overrun mcast
0 0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
Note: For some reason, Codesys and Con CAN seem to work, if the "CAN-Bus" and the "CANopen Manager" was NOT inserted in the Codesys Project (All "circles" are green in online mode).