Difference between revisions of "Example can"
(Page creation) |
|||
(4 intermediate revisions by 2 users not shown) | |||
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 the CAN bus. | ||
The <code>can</code> project builds one executable: <code>can</code>. | The <code>can</code> project builds one executable: <code>can</code>. | ||
Line 23: | Line 25: | ||
Alternatively, the <code>CMakefile.txt</code> can be used with the <code>cmake</code> command from the commandline to build and upload the example. For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]]. | Alternatively, the <code>CMakefile.txt</code> can be used with the <code>cmake</code> command from the commandline to build and upload the example. For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]]. | ||
+ | Code can be found at http://git.emacinc.com/OE/example-projects | ||
==Usage and Behavior== | ==Usage and Behavior== | ||
===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 39: | ||
<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"> | ||
+ | root@ipac9x25:~# ./can receive | ||
+ | <0x001> [8] 87 5a 6a 37 7a 94 a4 01 | ||
+ | root@ipac9x25:~# | ||
+ | </syntaxhighlight> | ||
+ | ===Usage Example for iPac9x25=== | ||
+ | You must first go into code and change the ifname to the name of your can port. The default example will use "can0". | ||
+ | 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 <data> | ||
+ | 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 the CAN bus. |
Latest revision as of 13:18, 30 November 2022
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 the CAN bus.
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.
Code can be found at http://git.emacinc.com/OE/example-projects
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:~#
Usage Example for iPac9x25
You must first go into code and change the ifname to the name of your can port. The default example will use "can0". Prepare Device 1 to receive:
root@ipac9x25:~# ./can receive
.
Send Data from Device 2:
root@somimx6ul:~# ./can send <data>
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 the CAN bus.