Difference between revisions of "How to use CAN bus"
From IGEP - ISEE Wiki
m |
m (→IGEPv2 EXPANSION) |
||
(10 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
=== IGEPv2 EXPANSION === | === IGEPv2 EXPANSION === | ||
− | + | ||
The IGEPv2 EXPANSION provides a CAN interface using MCP2515.<br> | The IGEPv2 EXPANSION provides a CAN interface using MCP2515.<br> | ||
Line 11: | Line 11: | ||
In order to test the CAN interface you can connect IGEPv2 EXPANSION to a CAN device or network or to another IGEPv2 EXPANSION. | In order to test the CAN interface you can connect IGEPv2 EXPANSION to a CAN device or network or to another IGEPv2 EXPANSION. | ||
+ | <section begin=IGEPv2 EXPANSION /> | ||
+ | You have to connect the two boards like this:<br> | ||
− | + | IGEPv2 1 IGEPv2 2 | |
− | + | .--- .--- | |
− | |||
− | .--- | ||
| 1 |-X X-| 1 | | | 1 |-X X-| 1 | | ||
− | | 2 |----------------| 2 | | + | | 2 |------------------| 2 | |
− | | 3 |----------------| 3 | | + | | 3 |------------------| 3 | |
− | | 4 |----------------| 4 | | + | | 4 |------------------| 4 | |
− | .--- | + | .--- .--- |
If this is your first time accessing CAN bus, check J702 jumper is not connected before follow this tutorial. If you don't have this jumper, don't worry because its function is only for testing. | If this is your first time accessing CAN bus, check J702 jumper is not connected before follow this tutorial. If you don't have this jumper, don't worry because its function is only for testing. | ||
Line 34: | Line 34: | ||
If you want to send CAN data, use: | If you want to send CAN data, use: | ||
− | cansend can0 | + | cansend can0 -i 0x123 0xaa 0xbb 0xcc 0xdd |
− | |||
− | |||
− | |||
On the receiver side, you must see the following messages: | On the receiver side, you must see the following messages: | ||
− | can0 123 [4] | + | can0 123 [4] aa bb cc dd |
− | |||
− | |||
− | |||
Switch roles and try it again | Switch roles and try it again | ||
<section end=IGEPv2 EXPANSION /> | <section end=IGEPv2 EXPANSION /> | ||
+ | |||
+ | === IGEP BERLIN === | ||
+ | |||
+ | The IGEP BERLIN provides a CAN interface using MCP2515.<br> | ||
+ | |||
+ | Several tools are provided by socketCAN to use this controller: | ||
+ | |||
+ | *candump: dump traffic on a CAN network. | ||
+ | *cansend: simple command line tool to send CAN-frames via CAN_RAW sockets. | ||
+ | *cangen: CAN frames generator for testing purpose. | ||
+ | *canplayer: send CAN frames from a file to a CAN interface. | ||
+ | |||
+ | In order to test the CAN interface you can connect IGEP BERLIN to a CAN device or network or to another IGEP BERLIN. | ||
+ | You have to connect the two boards like this:<br> | ||
+ | |||
+ | Board 1 Board 2 | ||
+ | .--- .--- | ||
+ | | 1 |------------------| 1 | | ||
+ | | 2 |------------------| 2 | | ||
+ | | 3 |------------------| 3 | | ||
+ | | 4 |-X X-| 4 | | ||
+ | | 5 |-X X-| 5 | | ||
+ | .--- .--- | ||
+ | |||
+ | Now you can set up the interface (on all boards when using multiple IGEP BERLIN <span lang="en" id="result_box" class="short_text"><span title="Click for alternate translations" class="hps">connected to a CAN network simultaneously)</span></span>:<br> | ||
+ | |||
+ | /bin/ip link set can0 up type can bitrate 125000 | ||
+ | |||
+ | If you want to receive CAN data, use: | ||
+ | |||
+ | candump can0 | ||
+ | |||
+ | If you want to send CAN data, use: | ||
+ | |||
+ | cansend can0 -i 0x123 0xaa 0xbb 0xcc 0xdd | ||
+ | |||
+ | On the receiver side, you must see the following messages: | ||
+ | |||
+ | can0 123 [4] aa bb cc dd | ||
+ | |||
+ | Switch roles and try it again | ||
[[Category:CAN bus]] | [[Category:CAN bus]] |
Latest revision as of 12:54, 10 September 2012
IGEPv2 EXPANSION
The IGEPv2 EXPANSION provides a CAN interface using MCP2515.
Several tools are provided by socketCAN to use this controller:
- candump: dump traffic on a CAN network.
- cansend: simple command line tool to send CAN-frames via CAN_RAW sockets.
- cangen: CAN frames generator for testing purpose.
- canplayer: send CAN frames from a file to a CAN interface.
In order to test the CAN interface you can connect IGEPv2 EXPANSION to a CAN device or network or to another IGEPv2 EXPANSION.
You have to connect the two boards like this:
IGEPv2 1 IGEPv2 2 .--- .--- | 1 |-X X-| 1 | | 2 |------------------| 2 | | 3 |------------------| 3 | | 4 |------------------| 4 | .--- .---
If this is your first time accessing CAN bus, check J702 jumper is not connected before follow this tutorial. If you don't have this jumper, don't worry because its function is only for testing.
Now you can set up the interface (on all boards when using multiple IGEPv2 EXPANSION connected to a CAN network simultaneously):
/bin/ip link set can0 up type can bitrate 125000
If you want to receive CAN data, use:
candump can0
If you want to send CAN data, use:
cansend can0 -i 0x123 0xaa 0xbb 0xcc 0xdd
On the receiver side, you must see the following messages:
can0 123 [4] aa bb cc dd
Switch roles and try it again
IGEP BERLIN
The IGEP BERLIN provides a CAN interface using MCP2515.
Several tools are provided by socketCAN to use this controller:
- candump: dump traffic on a CAN network.
- cansend: simple command line tool to send CAN-frames via CAN_RAW sockets.
- cangen: CAN frames generator for testing purpose.
- canplayer: send CAN frames from a file to a CAN interface.
In order to test the CAN interface you can connect IGEP BERLIN to a CAN device or network or to another IGEP BERLIN.
You have to connect the two boards like this:
Board 1 Board 2 .--- .--- | 1 |------------------| 1 | | 2 |------------------| 2 | | 3 |------------------| 3 | | 4 |-X X-| 4 | | 5 |-X X-| 5 | .--- .---
Now you can set up the interface (on all boards when using multiple IGEP BERLIN connected to a CAN network simultaneously):
/bin/ip link set can0 up type can bitrate 125000
If you want to receive CAN data, use:
candump can0
If you want to send CAN data, use:
cansend can0 -i 0x123 0xaa 0xbb 0xcc 0xdd
On the receiver side, you must see the following messages:
can0 123 [4] aa bb cc dd
Switch roles and try it again