Installing CAN bus drivers for OSD3358 systems running Debian kb-10

Octavo / Beaglebone Black  

Preparation:

You will need an OSD3358 board with CAN transceiver and networking installed.  Alternatively, the GHI OSD3358 dev board contains all of the necessary hardware.  These instructions establish DCAN1 as the default CAN bus device (it will show up as can0 in ifconfig). 

Procedure:

  1. Log into the OSD3358
  2. Install the can-utils package
    $ sudo apt-get install can-utils
     
  3. Enable the can interface (You will need to do this after every boot. You can add this to a startup script):
    $ sudo su
    # echo BB-CAN1 > /sys/devices/platform/bone_capemgr/slots
    # dmesg | grep -i can  This step is optional: view the dmesg log to make sure you don't see error messages and that the overlay loaded correctly
    # modprobe can
    # modprobe can-dev
    # modprobe can-raw
    # echo BB-CAN1 > /sys/devices/platform/bone_capemgr/slots

     
  4. Bring up the interface (again, you can do these in a script)
    # ip link set can0 type can bitrage 500000
    # ifconfig can0 up

     
  5. You can use the can-utils functions (like candump and cansend) to exercise the can interface from the command line.  Documentation is sparse, but I found these links useful:
    https://discuss.cantact.io/t/using-can-utils/24
    http://rpm.pbone.net/index.php3/stat/45/idpl/20350321/numer/8/nazwa/cansend and related pages
     
  6. This wikipedia article shows an example of using the can socket interface from a C program.  If you are using managed languages like C# via mono, you can turn this into a library that you call via PInvoke.
    https://en.wikipedia.org/wiki/SocketCAN

NOTE: This article will be updated as I continue to experiment with CAN

 

 
 
comments powered by Disqus