Difference between revisions of "Example can"
(Page creation) |
|||
Line 7: | Line 7: | ||
This is a guide to the <code>can</code> C example project included in the EMAC OE SDK. | This is a guide to the <code>can</code> C example project included in the EMAC OE SDK. | ||
− | + | A Controller Area Network (CAN bus) is a robust bus standard for in-vehicle networks. Originally designed for use in the automotive industry, CAN allows micro-controllers and devices to communicate through a message-based protocol with device priority and is used in many different applications to this day. | |
+ | |||
+ | This project serves as a demonstration of using CAN. | ||
The <code>can</code> project builds one executable: <code>can</code>. | The <code>can</code> project builds one executable: <code>can</code>. | ||
Line 27: | Line 29: | ||
===Hardware Requirements=== | ===Hardware Requirements=== | ||
− | + | It should run just fine on any device with a CAN interface. You will need: | |
+ | * Two devices with a CAN interface | ||
===Using <code>can</code>=== | ===Using <code>can</code>=== | ||
Line 35: | Line 38: | ||
<code>./can [send/recieve]</code> | <code>./can [send/recieve]</code> | ||
− | The program | + | The program will wait for data payload to be received (argument: "receive") through CAN or send data payload (argument: "send"), 8 random hex bytes, through CAN. The payload will then be printed on the receive end. |
===Usage Example=== | ===Usage Example=== | ||
− | + | Prepare Device 1 to receive: | |
+ | <syntaxhighlight lang="console"> | ||
+ | root@ipac9x25:~# ./can receive | ||
+ | . | ||
+ | </syntaxhighlight> | ||
+ | Send Data from Device 2: | ||
+ | <syntaxhighlight lang="console"> | ||
+ | root@somimx6ul:~# ./can send | ||
+ | root@somimx6ul:~# | ||
+ | </syntaxhighlight> | ||
+ | Device 1 received: | ||
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
− | root@ | + | root@ipac9x25:~# ./can receive |
− | + | <0x001> [8] 87 5a 6a 37 7a 94 a4 01 | |
+ | root@ipac9x25:~# | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
==Summary== | ==Summary== | ||
− | The <code>can</code> C example project demonstrates. | + | The <code>can</code> C example project demonstrates the use of CAN. |
Revision as of 12:18, 25 September 2020
This is a guide to the can
C example project included in the EMAC OE SDK.
A Controller Area Network (CAN bus) is a robust bus standard for in-vehicle networks. Originally designed for use in the automotive industry, CAN allows micro-controllers and devices to communicate through a message-based protocol with device priority and is used in many different applications to this day.
This project serves as a demonstration of using CAN.
The can
project builds one executable: can
.
Contents
Opening, Building and Uploading the Project Files
For information on opening the project from within Eclipse, please see Importing the EMAC OE SDK Projects with Eclipse. Then, follow Using the EMAC OE SDK Projects with Eclipse for information on how to build, upload and execute the example.
Alternatively, the Makefile
can be used with the make
command from the commandline to build and upload the example. For information on this method, please see Using EMAC OE SDK Example Projects.
EMAC SDK 5.X
For information on opening the project from within QtCreator, please see QtCreator: Adding Source Files. Then, follow Getting Started With Qt Creator for information on how to build, upload and execute the example.
Alternatively, the CMakefile.txt
can be used with the cmake
command from the commandline to build and upload the example. For information on this method, please see Getting Started with the EMAC OE SDK.
Usage and Behavior
Hardware Requirements
It should run just fine on any device with a CAN interface. You will need:
- Two devices with a CAN interface
Using can
The can
program is executed from the console. Requires either the argument "send" or "receive"
./can [send/recieve]
The program will wait for data payload to be received (argument: "receive") through CAN or send data payload (argument: "send"), 8 random hex bytes, through CAN. The payload will then be printed on the receive end.
Usage Example
Prepare Device 1 to receive:
root@ipac9x25:~# ./can receive
.
Send Data from Device 2:
root@somimx6ul:~# ./can send
root@somimx6ul:~#
Device 1 received:
root@ipac9x25:~# ./can receive
<0x001> [8] 87 5a 6a 37 7a 94 a4 01
root@ipac9x25:~#
Summary
The can
C example project demonstrates the use of CAN.