Difference between revisions of "Xenomai RTCAN"

From wiki.emacinc.com
Jump to: navigation, search
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{todo| NotStarted (03.03.2016-13:04->MW+)|Michael Welling| project=OE 5.0,MW,NotStarted }}
+
{{todo| Review (03.03.2016-13:04->MW+)(03.08.2016-14:00->MG+)|Michael Welling| project=OE 5.0,MW,MG,Review }}
 
{{#seo:
 
{{#seo:
 
|title=Xenomai RTCAN
 
|title=Xenomai RTCAN
Line 22: Line 22:
 
{{:Templateimpl:using | initials=MW | title=Xenomai RTCAN | desc=Xenomai RTCAN | project=OE 5.0 }}
 
{{:Templateimpl:using | initials=MW | title=Xenomai RTCAN | desc=Xenomai RTCAN | project=OE 5.0 }}
 
=== Loading the driver ===
 
=== Loading the driver ===
If a Linux driver has already been associated with the CAN interfaces it is required to unload the standard Linux driver or unbind that device for the driver.
+
If a Linux driver has already been associated with the CAN interfaces, it is required to unload the standard Linux driver or unbind that device for the driver.
 +
All of the examples below are using SoM-iMX6 for reference.
  
 
If the standard Linux CAN driver is built as a module, the module can just be unloaded using rmmod.
 
If the standard Linux CAN driver is built as a module, the module can just be unloaded using rmmod.
Line 38: Line 39:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Once the standard Linux CAN driver is unloaded the Xenomai real-time CAN driver can be loaded.
+
Once the standard Linux CAN driver is unloaded, the Xenomai real-time CAN driver can be loaded.
 
<syntaxhighlight lang="console">
 
<syntaxhighlight lang="console">
 
root@somimx6-xenomai:~# modprobe xeno_can_flexcan
 
root@somimx6-xenomai:~# modprobe xeno_can_flexcan
Line 53: Line 54:
 
With the real-time CAN driver loaded the <code>rtcanconfig</code> utility can be used to configure the bitrate and modes.   
 
With the real-time CAN driver loaded the <code>rtcanconfig</code> utility can be used to configure the bitrate and modes.   
 
<syntaxhighlight lang="console">
 
<syntaxhighlight lang="console">
root@somimx6-xenomai:/usr/demo# rtcanconfig rtcan0 --baudrate=125000 start
+
root@somimx6-xenomai:~# rtcanconfig rtcan0 --baudrate=125000 start
 
[  706.101002] rtcan0: real bitrate 125000, sampling point 87.5%
 
[  706.101002] rtcan0: real bitrate 125000, sampling point 87.5%
 
[  706.106857] rtcan0: writing ctrl=0x0e312005
 
[  706.106857] rtcan0: writing ctrl=0x0e312005
Line 66: Line 67:
 
Sending a CAN transaction using <code>rtcansend</code>.
 
Sending a CAN transaction using <code>rtcansend</code>.
 
<syntaxhighlight lang="console">
 
<syntaxhighlight lang="console">
root@somimx6-xenomai:/usr/demo# rtcansend rtcan0 -v -i 0x0 0x82 0x1
+
root@somimx6-xenomai:~# rtcansend rtcan0 -v -i 0x0 0x82 0x1
 
interface rtcan0
 
interface rtcan0
 
s=3, ifr_name=rtcan0
 
s=3, ifr_name=rtcan0
Line 72: Line 73:
 
Cleaning up...
 
Cleaning up...
 
</syntaxhighlight>
 
</syntaxhighlight>
Sending a CAN transaction using <code>rtcansend</code>.
+
Receiving a CAN transaction using <code>rtcanrecv</code>.
 
<syntaxhighlight lang="console">
 
<syntaxhighlight lang="console">
root@somimx6-xenomai:/usr/demo# rtcansend rtcan0 -v -i 0x0 0x82 0x1
+
root@somimx6-xenomai:~# rtcanrecv rtcan0 -v
 
interface rtcan0
 
interface rtcan0
 
s=3, ifr_name=rtcan0
 
s=3, ifr_name=rtcan0
<0x000> [2] 82 01
 
Cleaning up...
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
+
== External Links ==
<!-- /*********************************************************************************************************/ -->
+
* https://xenomai.org/documentation/xenomai-3/html/man1/rtcanconfig/index.html
<!-- /******************************************  More Information  *****************************************/ -->
+
* https://xenomai.org/documentation/xenomai-3/html/man1/rtcanrecv/index.html
<!-- /*********************************************************************************************************/ -->
+
* https://xenomai.org/documentation/xenomai-3/html/man1/rtcansend/index.html
{{:Templateimpl:moreinfo | initials=MW | title=Xenomai RTCAN | desc=Xenomai RTCAN | project=OE 5.0 }}
+
* https://xenomai.org/documentation/xenomai-3/html/xeno3prm/group__rtdm__can.html
*
 

Latest revision as of 14:03, 8 March 2016

TODO: {{#todo: Review (03.03.2016-13:04->MW+)(03.08.2016-14:00->MG+)|Michael Welling|OE 5.0,MW,MG,Review}}

General Information

Xenomai provides a RTDM profile for CAN device drivers enabling real-time CAN communication. The driver exposes a real-time interface similar to the standard SocketCAN interface. Xenomai provides several user-space tools to enable simple interface testing. The following sections will provide the information needed to load the CAN driver, configure the interface, and communicate using the command line utilities provided with Xenomai.

Xenomai RTCAN

Loading the driver

If a Linux driver has already been associated with the CAN interfaces, it is required to unload the standard Linux driver or unbind that device for the driver. All of the examples below are using SoM-iMX6 for reference.

If the standard Linux CAN driver is built as a module, the module can just be unloaded using rmmod.

root@somimx6-xenomai:~# lsmod
Module                  Size  Used by
can_raw                 6668  0 
can                    28850  1 can_raw
rt_fec                 14450  0 
rtnet                  51349  1 rt_fec
fec                    37316  0 
flexcan                 9971  0 
can_dev                11309  1 flexcan
root@somimx6-xenomai:~# rmmod flexcan

Once the standard Linux CAN driver is unloaded, the Xenomai real-time CAN driver can be loaded.

root@somimx6-xenomai:~# modprobe xeno_can_flexcan
[  662.498586] RT-Socket-CAN 0.90.2 - (C) 2006 RT-Socket-CAN Development Team
[  662.509318] 2090000.flexcan supply xceiver not found, using dummy regulator
[  662.516398] rtcan: registered rtcan0
[  662.520047] flexcan 2090000.flexcan: RTCAN device registered (reg_base=c0c70000, irq=142, clock=30000000)
[  662.529809] 2094000.flexcan supply xceiver not found, using dummy regulator
[  662.536881] rtcan: registered rtcan1
[  662.540504] flexcan 2094000.flexcan: RTCAN device registered (reg_base=c0c78000, irq=143, clock=30000000)

Configuring CAN interface

With the real-time CAN driver loaded the rtcanconfig utility can be used to configure the bitrate and modes.

root@somimx6-xenomai:~# rtcanconfig rtcan0 --baudrate=125000 start
[  706.101002] rtcan0: real bitrate 125000, sampling point 87.5%
[  706.106857] rtcan0: writing ctrl=0x0e312005
[  706.111091] rtcan0: flexcan_set_bit_time: mcr=0x5980000f ctrl=0x0e312005
[  706.117801] rtcan0: flexcan_chip_start: writing mcr=0x79a2020f
[  706.123511] rtcan0: flexcan_chip_start: writing ctrl=0x0e31ac55
[  706.129581] rtcan0: flexcan_chip_start: reading mcr=0x69a2020f ctrl=0x0e31ac55

Communicating with CAN

Xenomai provides two command line utilities to communicate with the CAN interface: rtcansend and rtcanrecv.

Sending a CAN transaction using rtcansend.

root@somimx6-xenomai:~# rtcansend rtcan0 -v -i 0x0 0x82 0x1
interface rtcan0
s=3, ifr_name=rtcan0
<0x000> [2] 82 01
Cleaning up...

Receiving a CAN transaction using rtcanrecv.

root@somimx6-xenomai:~# rtcanrecv rtcan0 -v
interface rtcan0
s=3, ifr_name=rtcan0

External Links