Difference between revisions of "GettingStarted"
(init GettingStarted) |
m (minor: missing to) |
||
Line 120: | Line 120: | ||
# start canopen-posix-test on the other side | # start canopen-posix-test on the other side | ||
− | # for that go the canopen folder you've used in previous step to build | + | # for that go to the canopen folder you've used in previous step to build |
# a binary as this needs to be started by root (or use su -c ".." as a normal user) | # a binary as this needs to be started by root (or use su -c ".." as a normal user) | ||
./build/canopen-posix-test/tower_init <> /dev/ttyS1 > /dev/ttyS1 | ./build/canopen-posix-test/tower_init <> /dev/ttyS1 > /dev/ttyS1 |
Latest revision as of 01:18, 30 September 2017
Contents
Required equip
- Linux computer
- F4 Discovery board
- CAN4DISCO board
- STLink programmer(s)
- Slave nodes
Software stack
You can build the complete stack according to instruction on distrap-build repository.
UDev rules
For persistent device names you should create udev rules files in /etc/udev/rules.d/. For example to create rules for your F4 Discovery board flashed with Black Magic probe firmware you can use the following template:
# F4 Discovery
SUBSYSTEMS=="usb", ATTRS{manufacturer}=="Black Sphere Technologies", ATTRS{serial}!="E3C09CF4", GOTO="f4_bmp_end"
ACTION=="add", SUBSYSTEM=="tty", ATTRS{interface}=="Black Magic GDB Server", MODE="0660", GROUP="dialout", SYMLINK+="f4gdb"
ACTION=="add", SUBSYSTEM=="tty", ATTRS{interface}=="Black Magic UART Port", MODE="0660", GROUP="dialout", SYMLINK+="f4uart"
LABEL="f4_bmp_end"
Make sure to set correct serial number, this can be found by running dmesg after the board is plugged in. Create similar file as /etc/udev/rules.d/48-distrap.rules and run
udevadm control -R
to reload UDev daemon. Next time you plug in your device two nodes should be created
- /dev/f4gdb - for attaching GDB
- /dev/f4uart - UART2 pass-through
Hardware
Flashing
Debugging
Black Magic Probe
CAN
Either you Linux computer or single board computer like Raspberry Pi or BeagleBone Black can be used as CAN master. For development purposes powerful computer is better due to shorter compilation time, for production BeagleBone Black or ODROID XU4 is a good choice.
Bringing up SLCAN bridge
Assuming you are using CAN4DISCO as UART2CAN bridge you can bring up CAN network with following commands:
modprobe can
modprobe can-raw
modprobe slcan
slcand -F -s8 -S115200 /dev/f4uart can0 # CAN speed 8 -> 1Mbit
ip link set can0 up
Script to initialize SLCAN can be found in distrap/dumpster.
Brining up native interface
Using virtual CAN interface
Virtual CAN interface can be started with following commands:
modprobe can
modprobe can-raw
modprobe vcan
ip link add type vcan
ip link add dev vcan0 type vcan
ip link set vcan0 up
Script to initialize vcan0 can be found in distrap/dumpster.
Monitoring CAN traffic
candump utility can be used to dump traffic on the CAN interface:
candump can0
# or
# candump vcan0
Sending CAN messages manually
Use cansend utility, for example to send LSS identify uncofigured devices command:
cansend can0 7E5#4C
If you have such unconfigured node connected you should see its reply in candump:
# candump can0
can0 7E5 [1] 4C
can0 7E4 [8] 50 00 00 00 00 00 00 00
Running CANOpen node on POSIX
Build canopen-posix-test
cd distrap-build/canopen/
make canopen-posix-test
As root create virtual terminal pair (linking /dev/ttyS0 with /dev/ttyS1) and start SLCAN on one side and POSIX node on the other side (POSIX node utilizes SLCAN on its side as well to convert SLCAN traffic to CAN traffic internally). To do so start the following commands as root:
socat -d -d pty,link=/dev/ttyS0,raw,echo=0 pty,link=/dev/ttyS1,raw,echo=0
# start slcand on one side
slcand -F -s8 -S115200 /dev/ttyS0 can0
ip link set can0 up
# start canopen-posix-test on the other side
# for that go to the canopen folder you've used in previous step to build
# a binary as this needs to be started by root (or use su -c ".." as a normal user)
./build/canopen-posix-test/tower_init <> /dev/ttyS1 > /dev/ttyS1
Now the node is running and should respond to messages. It first needs to be configured (node ID is set during LSS phase) and then it can be used for testing fully featured CANOpen communication. Try talking to it as described in section #Sending CAN messages manually.