$ sudo apt-get install manpages-dev manpages-posix-dev
manpages-dev: Manual pages about using GNU/Linux for development
manpages-posix-dev: Manual pages about using a POSIX system for development
$ sudo apt-get install manpages-dev manpages-posix-dev
manpages-dev: Manual pages about using GNU/Linux for development
manpages-posix-dev: Manual pages about using a POSIX system for development
Three steps:
Add following line in /etc/default/capemgr
CAPE=BB-DCAN1
Add following lines in /etc/network/interfaces
auto can0 iface can0 inet manual pre-up /sbin/ip link set $IFACE type can bitrate 1000000 listen-only off up /sbin/ifconfig $IFACE up down /sbin/ifconfig $IFACE down
Setting the CAN interface to /etc/network/interface does not enable the CAN interface on startup for some reason. In order to workaround this problem, I installed a startup program as follows.
Following link was helpful:
Running a script on Beaglebone Black boot/ startup
The startup script to run on startup is as follows. This script also turns off wi-fi power management, thus I removed a cron entry I added before to disable the power management.
naoki@beaglebone:~$ cat /usr/bin/startup.sh #!/bin/sh ifup -a /sbin/iwconfig wlan0 power off
Following are the steps to create and enable a service that runs on startup.
vi /lib/systemd/startup.service
[Unit]
Description=runs startup script after startup
After=syslog.target network.target
[Service]
Type=simple
ExecStart=/usr/bin/startup.sh
[Install]
WantedBy=multi-user.target
cd /etc/systemd/system/
ln -s /lib/systemd/startup.service startup.service
systemctl daemon-reload
systemctl start scriptname.service
systemctl enable scriptname.service
reboot
The operating system is Debian. This is a dirty solution but it does work anyway.
root@beaglebone:~# cat /etc/pm/power.d/wlan0_pm_off #!/bin/bash [ -x /sbin/iwconfig ] || exit 0 [ -n "`/sbin/iwconfig 2>/dev/null | grep wlan0`" ] || exit 0 /sbin/iwconfig wlan0 power off root@beaglebone:~# crontab -l | grep -v "^#" */1 * * * * /etc/pm/power.d/wlan0_pm_off root@beaglebone:~# iwconfig wlan0 wlan0 IEEE 802.11abgn ESSID:"*****" ... Power Management:off ...
Following operations seem to be necessary every BeagleBone boot. TBD to setup auto configuration on startup.
root@beaglebone:~# echo BB-DCAN1 > /sys/devices/platform/bone_capemgr/slots root@beaglebone:~# ip link set can0 up type can bitrate 500000 root@beaglebone:~# ip link set can0 up type can bitrate 1000000 root@beaglebone:~# ifconfig can0 can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 UP RUNNING NOARP MTU:16 Metric:1 RX packets:2 errors:0 dropped:2 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:10 RX bytes:16 (16.0 B) TX bytes:0 (0.0 B) Interrupt:192 root@beaglebone:~# ip -d -s link show can0 4: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 10 link/can promiscuity 0 can state ERROR-ACTIVE (berr-counter tx 0 rx 127) restart-ms 0 bitrate 1000000 sample-point 0.750 tq 83 prop-seg 4 phase-seg1 4 phase-seg2 3 sjw 1 c_can: tseg1 2..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1 clock 24000000 re-started bus-errors arbit-lost error-warn error-pass bus-off 0 0 0 1 1 0 RX: bytes packets errors dropped overrun mcast 16 2 0 2 0 0 TX: bytes packets errors dropped carrier collsns 0 0 0 0 0 0
Used MCP2551 for CAN transceiver.
Pin 24 -> CAN RX Pin 26 -> CAN TX Pin 2 -> GND Pin 6 -> VDD 5V
See the picture above.
naoki-macbook:~ naoki$ screen /dev/tty.usbmodem14244421
root@beaglebone:~# candump can0 can0 100 [3] 09 4A 46 can0 100 [3] 08 4A 00
Serial port monitor:
note on [ 01 00] 4a note off [ 01 00] 4a