Wilbert's website at SocSci

has a subtitle

computer/canable.html 2018-11-30

Canable

notes on how to connect two canables to linux (ubuntu 18.04 bionic)

canable with slcan firmware

0 connect:

lsusb
	Bus 003 Device 009: ID ad50:60c4
one led will blink and then go off, the other will stay on

1 make a serial device

# all devices have the same id: /dev/serial/by-id/usb-CANtact_CANtact_dev_00000000001A-if00
ls -la /dev/ttyA*
sudo slcand -o -s8 -t hw -S 1000000 /dev/ttyACM0
sudo slcand -o -s8 -t hw -S 1000000 /dev/ttyACM1
# slcand should still be running after starting it, otherwise something went wrong
ps -A | grep slcand

2 make a socket

sudo ip link show
sudo ip link set up slcan0
sudo ip link set up slcan1

3 test

cansend slcan0 '999#DEADBEEF'
ifconfig
slcan0: flags=193  mtu 16
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 10  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1  bytes 4 (4.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

slcan1: flags=193  mtu 16
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 10  (UNSPEC)
        RX packets 1  bytes 4 (4.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

candump slcan1
cansend slcan0 '999#DEADBEEF'

canable with candlelight firmware

Download bin file

https://canable.io/builds/

Connect

change jumper to bootloader mode, connect
lsusb
	Bus 003 Device 015: ID 0483:df11 STMicroelectronics STM Device in DFU Mode

flash

sudo dfu-util -d 0483:df11 -c 1 -i 0 -a 0 -s 0x08000000 -D gsusb_canable.bin

terra:candlelight-firmware> sudo dfu-util -d 0483:df11 -c 1 -i 0 -a 0 -s 0x08000000 -D gsusb_canable.bin 

dfu-util 0.9
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 0483:df11
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuERROR, status = 10
dfuERROR, clearing status
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 2048
DfuSe interface name: "Internal Flash  "
Downloading to address = 0x08000000, size = 30724
Download        [=========================] 100%        30724 bytes
Download done.
File downloaded successfully

reconnect

change jumper back and reconnect
lsusb
    Bus 003 Device 031: ID 1d50:606f OpenMoko, Inc. 

sudo ip link show
12: can0:  mtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10
    link/can 

sudo ip link set can0 type can bitrate 1000000
sudo ip link set up can0 # both LEDS go off
without the first line it gives:
RTNETLINK answers: Invalid argument
dmesg: [  160.105940] gs_usb 3-13:1.0 can0: bit-timing not yet defined

automate

# setting up so that the above two lines happen automatically at connect usb:
/etc/udev/rules.d/10-can.network.rules
SUBSYSTEM=="net", KERNEL=="can[0-9]", RUN+="/sbin/ip link set can%n type can bitrate 1000000" 
/etc/udev/rules.d/11-can.network.rules
SUBSYSTEM=="net", KERNEL=="can[0-9]", RUN+="/sbin/ip link set up can%n"
Canable leds will both show for about 1s and then go off

test

as above, buth sockets are now called can0 and can1