How to Use CAN CAPE for Beaglebone Black?


#1

I have recently purchased a Beaglebone Black and the CAN CAPE, COMCPE-BBBCAPE
I need to receive CAN messages, combine the content of the data, and send it out the Ethernet port of the Beaglebone using UDP.
I’m looking for example code for the CAN CAPE. I struggling to find details on how to use the CAN CAPE that I purchased.
I’d like to use Python or Javascript, but would accept most any language.


#2

Well the can pins are using P9.24/P9.26

First double check that they loaded:

sudo /opt/scripts/tools/version.sh

Then take a look at these two sites on can:

https://elinux.org/CAN_Bus

Regards,


#3

Hi Robert,

Thank you for this information.

I have looked at the GitHub link you provided and see two different source files, candump.c and cansniffer.c that I believe would get me on the right path.

Can you tell me what I need to do to my Beaglebone Black with the CAN Cape to get the code candump.c to actually run?

Thanks,

Dave


#4

You can build that project by following this:

sudo apt update
sudo apt install build-essential cmake git ninja-build

git clone https://github.com/linux-can/can-utils
cd ./can-utils/
mkdir build
cd ./build/
cmake -GNinja .. && ninja
debian@beaglebone:~/can-utils/build$ cmake -GNinja .. && ninja
-- The C compiler identification is GNU 6.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/debian/can-utils/build
[48/63] Building C object CMakeFiles/c...bit-timing.dir/can-calc-bit-timing.c.o
/home/debian/can-utils/can-calc-bit-timing.c: In function ‘print_bit_timing’:
/home/debian/can-utils/can-calc-bit-timing.c:447:35: warning: ‘tseg1’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  unsigned int brp, tsegall, tseg, tseg1, tseg2;
                                   ^~~~~
/home/debian/can-utils/can-calc-bit-timing.c:447:42: warning: ‘tseg2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  unsigned int brp, tsegall, tseg, tseg1, tseg2;
                                          ^~~~~
[63/63] Linking C executable isotpsniffer
debian@beaglebone:~/can-utils/build$ ls
asc2log              canlogserver         isotprecv     libcan.a
bcmserver            canplayer            isotpsend     libj1939.a
build.ninja          cansend              isotpserver   log2asc
canbusload           cansniffer           isotpsniffer  log2long
can-calc-bit-timing  CMakeCache.txt       isotptun      rules.ninja
candump              CMakeFiles           jacd          slcan_attach
canfdtest            cmake_install.cmake  jcat          slcand
cangen               isotpdump            jspy          slcanpty
cangw                isotpperf            jsr           testj1939

Regards,