hc
2024-11-01 2f529f9b558ca1c1bd74be7437a84e4711743404
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
Utilities for RT-Socket-CAN
===========================
 
For further information on RT-Socket-CAN, especially the kernel space
part, please have a look to "kernel/drivers/can/README".
 
Installation:
------------
 
Please install the Xenomai user space part as described in the
README.INSTALL.
 
  $ export CROSS_COMPILE=ppc_82xx-
  $ cd <xenomai-root>
  $ ./configure --prefix=/usr/xenomai --host=ppc-linux
  $ make
  $ export DESTDIR=/opt/eldk/ppc_82xx
  $ make install
 
Utilities for RT-Socket-CAN are available in "src/drivers/can".
With "make install" they get copied to the Xenomai installation
directory.
 
 
Running and using RT-Socket-CAN:
-------------------------------
 
Now boot the Xenomai enabled kernel on your target system.
 
In case RT-Socket-CAN is built as kernel modules, you need to load
them using modprobe or insmod, e.g. for this example build:
 
  # export MODDIR=/lib/modules/2.4.25/kernel/drivers/xenomai/rtcan
  # insmod $MODDIR/xeno_can.o
  # insmod $MODDIR/mscan/xeno_can_mscan.o
  # insmod $MODDIR/sja1000/xeno_can_sja1000.o
  # insmod $MODDIR/sja1000/xeno_can_peak_pci.o
 
Note that various kernel module parameters can be passed with insmod.
Please use "modinfo" to list them or check the corresponding source
code files for further information
 
There are a few RT-Socket-CAN utilities to configure RTCAN and to send
and receive CAN messages, which have been installed in the Xenomai
installation directory with "make install":
 
  # export XENO_ROOT=/usr/xenomai
  # export PATH=$PATH:$XENO_ROOT/bin
  # export LD_LIBRARY_PATH=$XENO_ROOT/lib
 
  # rtcanconfig --help
  Usage: rtcanconfig <can-interface> [Options] [up|down|start|stop|sleep]
  Options:
   -v, --verbose            be verbose
   -h, --help               this help
   -c, --ctrlmode=M1:M2:... listenonly or loopback mode
   -b, --baudrate=BPS       baudrate in bits/sec
   -B, --bittime=BTR0:BTR1  BTR or standard bit-time
   -B, --bittime=BRP:PROP_SEG:PHASE_SEG1:PHASE_SEG2:SJW:SAM
 
  # rtcanrecv --help
  Usage: rtcanrecv <can-interface> [Options]
  Options:
   -f  --filter=id:mask[:id:mask]... apply filter
   -e  --error=mask      receive error messages
   -t, --timeout=MS      timeout in ms
   -v, --verbose         be verbose
   -p, --print=MODULO    print every MODULO message
   -n, --name=STRING     name of the RT task
   -h, --help            this help
 
  # rtcansend --help
  Usage: rtcansend <can-interface> [Options] <can-msg>
  <can-msg> can consist of up to 8 bytes given as a space separated list
  Options:
   -i, --identifier=ID   CAN Identifier (default = 1)
   -r  --rtr             send remote request
   -e  --extended        send extended frame
   -l  --loop=COUNT      send message COUNT times
   -c, --count           message count in data[0-3]
   -d, --delay=MS        delay in ms (default = 1ms)
   -t, --timeout=MS      timeout in ms
   -v, --verbose         be verbose
   -p, --print=MODULO    print every MODULO message
   -h, --help            this help
 
Here are a few self-explanary commands:
 
  # rtcanconfig rtcan0 --baudrate=125000 start
 
  # rtcansend rtcan2 --verbose --identifier=0x123 0xde 0xad
  <0x123> [2] de ad
 
  # rtcanrecv rtcan0 --verbose
  #1: <0x123> [2] de ad
 
  bash-2.05b# rtcanrecv rtcan0 --filter=0x120:0x120
  Filter #0: id=0x00000120 mask=0x00000120
  #0: <0x124> [2] de ad
  #1: <0x123> [3] 12 34 56
  #2: <0x133> [4] 11 22 33 44
 
  # rtcanrecv rtcan0 --error=0xffff
  #1: !0x00000008! [8] 00 00 80 19 00 00 00 00 ERROR
 
 
PROC filesystem: the followingfiles provide useful information
on the status of the CAN controller, filter settings, registers,
etc.
 
  # cat /proc/rtcan/devices
  Name___________ _Baudrate State___ TX_Counter RX_Counter ____Errors
  rtcan0             125000 active            0          8          0
  rtcan1             125000 active            0          8          0
  rtcan2             125000 passive           8          0      14714
 
  # cat /proc/rtcan/sockets
  fd Name___________ Filter ErrMask RX_Timeout_ns TX_Timeout_ns RX_BufFull
   0 rtcan0               1 0x0ffff      infinite      infinite          0
   1 rtcan0               1 0x00000      infinite      infinite          0
 
  # cat /proc/rtcan/rtcan2/info
  Device     rtcan2
  Controller SJA1000
  Board      PEAK-PCI
  Clock-Hz   8000000
  Baudrate   125000
  Bit-time   brp=4 prop_seg=0 phase_seg1=13 phase_seg2=2 sjw=1 sam=0
  Ctrl-Mode
  State      passive
  TX-Counter 3
  RX-Counter 0
  Errors     45424
  Refcount   0
 
  # cat /proc/rtcan/rtcan0/filters
  fd __CAN_ID__ _CAN_Mask_ MatchCount
   0 0x00000000 0x00000000          0
   1 0x00000120 0x00000120          3
 
  # cat /proc/rtcan/rtcan0/registers
  MSCAN registers at f0000900
  canctl0  0x90 rxfrm synch
  canctl1  0xc0 cane clksrc
  ...
 
  # cat /proc/rtcan/rtcan2/registers
  SJA1000 registers
  00: 00 00 4c 00 ff 00 03 1c 1a 00 00 02 d6 60 14 88
  10: 02 26 60 de ad 04 04 00 ef c7 ef ef 40 00 00 c7