TS-7670 CAN: Difference between revisions
No edit summary |
No edit summary |
||
Line 12: | Line 12: | ||
#This command will return | #This command will return | ||
can0 123 [4] DE AD BE EF | can0 123 [4] DE AD BE EF | ||
</source><br> | |||
In order to set the baud rate of either CAN interface, the interface must first be brought down with: | |||
<source lang="bash"> | |||
ifconfig canX down | |||
</source><br> | |||
Where "X" is interface 0 or 1. At this point, the desired baud rate can be directly entered in to the file "/sys/devices/platform/FlexCAN.X/bitrate", where X is the desired interface. For example, to set a baud rate of 750kHz on both interfaces: | |||
<source lang="bash"> | |||
echo 750000 > /sys/devices/platform/FlexCAN.0/bitrate | |||
echo 750000 > /sys/devices/platform/FlexCAN.1/bitrate | |||
</source><br> | </source><br> | ||
See the [http://developer.berlios.de/projects/socketcan/ SocketCAN] webpage for more information on utilizing SocketCAN. | See the [http://developer.berlios.de/projects/socketcan/ SocketCAN] webpage for more information on utilizing SocketCAN. |
Revision as of 11:51, 2 October 2014
The TS-7670 i.MX286 CPU has two FlexCAN ports that use the linux SocketCAN implementation. The ports can be set up and used with the following commands:
modprobe flexcan
ifconfig can0 up
ifconfig can1 up
At this point the ports can be used with standard SocketCAN libraries. In debian we provide cansend and candump to test the ports or as a simple packet send/recv tool. In order to test the two ports together, tie CAN_H of both CAN ports together, and do the same for CAN_L. Then use the following commands:
candump can0 &
cansend can1 123#DEADBEEF
#This command will return
can0 123 [4] DE AD BE EF
In order to set the baud rate of either CAN interface, the interface must first be brought down with:
ifconfig canX down
Where "X" is interface 0 or 1. At this point, the desired baud rate can be directly entered in to the file "/sys/devices/platform/FlexCAN.X/bitrate", where X is the desired interface. For example, to set a baud rate of 750kHz on both interfaces:
echo 750000 > /sys/devices/platform/FlexCAN.0/bitrate
echo 750000 > /sys/devices/platform/FlexCAN.1/bitrate
See the SocketCAN webpage for more information on utilizing SocketCAN.