Difference between revisions of "Application note - CANbus on fitlet2 with FC-SCG running Linux"

From fit-PC wiki
Jump to: navigation, search
 
(17 intermediate revisions by 2 users not shown)
Line 1: Line 1:
fitlet2 supports CAN if configured with the [http://fit-pc.com/wiki/index.php/Fitlet2_FACET_Cards#FC-SCG FC-SCG FACET].
+
* This application note applies to [[fitlet2]] with [http://fit-pc.com/wiki/index.php/Fitlet2_FACET_Cards#FC-SCG FC-SCG] FACET-Card running Linux
 +
* It provides an example of how to use the CANbus feature of FC-SCG under Linux
 +
* The following application is required for the CAN bus functionality: [https://fit-iot.com/files/download/fitlet2/sw/drivers/Linux/fitlet2-linux-FTDI-CAN-sniffer-master.tar.gz fitlet2 FTDI CAN sniffer]
  
The following application is required for the CAN bus functionality:
+
==Simple CAN bus sniffer==
  
<br>*[https://fit-iot.com/files/download/fitlet2/sw/drivers/Linux/fitlet2-linux-FTDI-CAN-sniffer-master.zip fitlet2 FTDI CAN sniffer]
+
Written for the following chain: [https://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT232H.pdf FTDI232H] <-> [https://www.microchip.com/wwwproducts/en/en010406 MCP2515].<br>
 +
Tested on Linux 4.14.41 (Debian sid)
 +
 
 +
Prerequisites:
 +
[https://code.google.com/archive/p/libmpsse/downloads libmpsse-1.3]
 +
libftdi1-1.4 via https://www.intra2net.com/en/developer/libftdi/repository.php
 +
libusb-1.0  via https://libusb.info/
 +
 
 +
Avaliable binaries:
 +
sniff -- dynamically linked against mentioned libraries
 +
sniff.static -- statically linked executable
 +
 
 +
'''Usage:'''
 +
 
 +
Prints received frames to STDOUT, sends to net frames gotten from STDIN.
 +
Options:
 +
 
 +
        --can_bitrate Hz        required CAN bus speed
 +
        --can_osc Hz            CAN clock oscillator frequency in fact
 +
decimal modifiers 'k' and 'M' are allowed
 +
 
 +
        --promiscuous [01]      a given RX buffer is to receive all frames
 +
        --rollover              rollover mode for RX buffer 0
 +
        --mask [01]:sid-eid    acceptance mask for a mentioned RX buffer
 +
        --filter [012345]:sid-eid      acceptance filter
 +
 
 +
filters 0 and 1 are purposed for RX buffer 0 and the others for RX buffer 1
 +
        mask and filters format: n:sid-eid
 +
        where:
 +
        num    number of mask or filter
 +
        sid    Standard identifier of mask/filter
 +
        eid    enhanced identifier of mask/filter
 +
Omitted eid (if any) will be zeroed.
 +
 
 +
        --sniff                listen-only mode
 +
        --showraw              print out frames received/to be sent in hex
 +
 
 +
Allowed frame to be sent format:
 +
sid:paiload[0...i]
 +
sid-eid:paiload[0...i]
 +
* where "i" must be less than 8
 +
 
 +
For more detailed explanation of the mentioned options please read the MCP2515 datasheet:<br>
 +
[http://ww1.microchip.com/downloads/en/DeviceDoc/20001801H.pdf MCP2515 CAN bus interface chip datasheet]
  
  
Line 9: Line 54:
 
[[category: software]]
 
[[category: software]]
 
[[category: Extension boards]]
 
[[category: Extension boards]]
 +
[[category: application notes]]

Latest revision as of 10:49, 16 October 2018

  • This application note applies to fitlet2 with FC-SCG FACET-Card running Linux
  • It provides an example of how to use the CANbus feature of FC-SCG under Linux
  • The following application is required for the CAN bus functionality: fitlet2 FTDI CAN sniffer

Simple CAN bus sniffer

Written for the following chain: FTDI232H <-> MCP2515.
Tested on Linux 4.14.41 (Debian sid)

Prerequisites: libmpsse-1.3

libftdi1-1.4 via https://www.intra2net.com/en/developer/libftdi/repository.php
libusb-1.0   via https://libusb.info/

Avaliable binaries:

sniff -- dynamically linked against mentioned libraries
sniff.static -- statically linked executable

Usage:

Prints received frames to STDOUT, sends to net frames gotten from STDIN. Options:

       --can_bitrate Hz        required CAN bus speed
       --can_osc Hz            CAN clock oscillator frequency in fact

decimal modifiers 'k' and 'M' are allowed

       --promiscuous [01]      a given RX buffer is to receive all frames
       --rollover              rollover mode for RX buffer 0
       --mask [01]:sid-eid     acceptance mask for a mentioned RX buffer
       --filter [012345]:sid-eid       acceptance filter

filters 0 and 1 are purposed for RX buffer 0 and the others for RX buffer 1

       mask and filters format: n:sid-eid
       where:
       num     number of mask or filter
       sid     Standard identifier of mask/filter
       eid     enhanced identifier of mask/filter

Omitted eid (if any) will be zeroed.

       --sniff                 listen-only mode
       --showraw               print out frames received/to be sent in hex

Allowed frame to be sent format:

sid:paiload[0...i]
sid-eid:paiload[0...i]
  • where "i" must be less than 8

For more detailed explanation of the mentioned options please read the MCP2515 datasheet:
MCP2515 CAN bus interface chip datasheet