EMAC CAN Interface

From wiki.emacinc.com
Revision as of 16:31, 18 January 2016 by Kyoungmeyer (talk | contribs)
Jump to: navigation, search
TODO: {{#todo: InProgress (01.18.2016-10:45->KY+)|Klint Youngmeyer|OE 5.0,KY,InProgress}}

The CAN interface is a vehicle bus standard that allows communication between a controller and various sensors. EMAC produces several boards capable of communicating on a CAN bus. For more information about which products support the CAN bus, see the hardware page.

Background

CAN (controller area network) is a multi-master serial bus for communicating between "nodes" over a two-wire interface. The wires are generally a 120 ohm twisted pair. Each CAN node has the ability to communicate with every other node, one at a time.

EMAC CAN Interface

The CAN bus is able to be accessed from the command line, or using a C API on EMAC products (with CAN support).

CAN Bus Setup

Before using the CAN interface on an EMAC device, two commands must be run. These commands could be scripted to be run at startup.



NOTE
The settings in the first command may need to be changed according to the application in question.


root@ipac9x25:~# ip link set can0 type can bitrate 125000 triple-sampling on


root@ipac9x25:~# ip link set can0 up

Command Line CAN

The command line tools included with EMAC OE 5 are part of the canutils package. The tools included in this package are:

  • canconfig
  • candump
  • canecho
  • cansend
  • cansequence

Of these five, the most easily used are cansend and candump.

cansend

cansend, as the name implies, is used for sending CAN messages over the bus. Up to eight bytes at a time can be sent using cansend, these bytes are formatted at a space separated list of hexadecimal octets e.g. "0xBE 0x42 0xEF 0x9A." The command for sending the previous hexadecimal digits on the can0 device is:

root@ipac9x25:~# cansend can0 0xBE 0x42 0xEF 0x9A

Identity

candump

Conclusion

Further Information

Where to Go Next
Pages with Related Content