Lely core libraries  1.9.2
doc/co/coctl.md
1 coctl - CANopen control tool
2 ============================
3 
4 Synopsis
5 --------
6 
7  coctl -h
8  coctl --help
9  coctl [-e | --exit] [-i ms | --inhibit=ms] [-m | --monitor] [-W | --no-wait]
10  [interface filename]...
11 
12 Description
13 -----------
14 
15 The CANopen control tool provides shell-like access to one or more CANopen
16 networks according to the ASCII gateway protocol (CiA 309-3).
17 
18 The options are as follows:
19 
20  -e, --exit Exit on error.
21  -h, --help Display help.
22  -i <ms>, --inhibit=<ms>
23  Wait at least <ms> milliseconds between requests
24  (default: 100).
25  -m, --monitor Do not exit on EOF (monitor mode).
26  -W, --no-wait Do not wait for the previous command to complete
27  before accepting the next one.
28 
29 For each of the CANopen networks the gateway needs to access, a CAN interface
30 and an EDS/DCF filename must be provided. The networks are numbered
31 sequentially, starting with 1.
32 
33 Syntax
34 ------
35 
36 The gateway is controlled by commands. A command is composed of tokens, which
37 are separated by whitespace, and is terminated by a new-line character.
38 Whitespace is handled as specified in [ISO/IEC 9899].
39 
40 Commands are case insensitive. Some commands have short form as well as a long
41 form. The long form is obtained by concatenating the short form and the string
42 enclosed in brackets (e.g., "r[ead]" can be specified as both "r" and "read").
43 
44 Network- and node-level commands are prefixed with a network and/or node number
45 (in the range [1..127]). These numbers can be omitted if default values are set
46 (with `set network` and `set node`, respectively). `[net]` and
47 `[[net] node]` indicate which commands require a prefix.
48 
49 The gateway prepends a sequence number (enclosed in brackets) to each command.
50 The confirmation of the command also begins with the same sequence number. This
51 allows the user to match responses to requests. Event-triggered messages from
52 the gateway do not begin with a sequence number.
53 
54 ### Data types
55 
56 Some SDO and PDO commands require data type indications. The data type syntax is
57 provided in the following table:
58 
59 Syntax | CANopen data type
60 ------ | -----------------
61 b | BOOLEAN
62 u8 | UNSIGNED8
63 u16 | UNSIGNED16
64 u24 | UNSIGNED24
65 u32 | UNSIGNED32
66 u40 | UNSIGNED40
67 u48 | UNSIGNED48
68 u56 | UNSIGNED56
69 u64 | UNSIGNED64
70 i8 | INTEGER8
71 i16 | INTEGER16
72 i24 | INTEGER24
73 i32 | INTEGER32
74 i40 | INTEGER40
75 i48 | INTEGER48
76 i56 | INTEGER56
77 i64 | INTEGER64
78 r32 | REAL32
79 r64 | REAL64
80 t | TIME_OF_DAY
81 td | TIME_DIFFERENCE
82 vs | VISIBLE_STRING
83 os | OCTET_STRING
84 us | UNICODE_STRING
85 d | DOMAIN
86 
87 Numerical values are represented as specified in [ISO/IEC 9899]. Values of data
88 type TIME_OF_DAY and TIME_DIFFERENCE consist of two unsigned integers separated
89 by whitespace. Values of data type VISIBLE_STRING are enclosed with double
90 quotes. If a double quote is used within the string, it is escaped by a second
91 quote (e.g, "Hello, ""World""!"). Other escape sequences as specified in
92 [ISO/IEC 9899] are allowed. Values of data type OCTET_STRING, UNICODE_STRING and
93 DOMAIN are encoded in MIME Base64 (as specified in [RFC 2045]).
94 
95 ### Bit-rates
96 
97 The 'Initialize gateway' (`init`) and 'LSS configure bit-rate'
98 (`lss_conf_bitrate`) commands require a bit-rate indication. Bit-rates are
99 specified with a table_selector and table_index. The only value currently
100 supported for table_selector is 0. The valid values for table_index are provided
101 in the following table:
102 
103 table_index | Bit rate
104 ----------- | ----------------------------
105 0 | 1000 kbit/s
106 1 | 800 kbit/s
107 2 | 500 kbit/s
108 3 | 250 kbit/s
109 4 | 125 kbit/s
110 5 | reserved
111 6 | 50 kbit/s
112 7 | 20 kbit/s
113 8 | 10 kbit/s
114 9 | Automatic bit rate detection
115 
116 [ISO/IEC 9899]: http://www.open-std.org/jtc1/sc22/wg14/www/standards.html
117 [RFC 2045]: https://tools.ietf.org/html/rfc2045
118 
119 SDO access services
120 -------------------
121 
122 ### Upload SDO
123 
124  [[net] node] r[read] <multiplexer> <datatype>
125 
126 Initiates an SDO upload service. `<multiplexer>` is a combination of an object
127 index and sub-index, while `<datatype>` must be one of the values in the table
128 above.
129 
130 ### Download SDO
131 
132  [[net] node] w[rite] <multiplexer> <datatype> <value>
133 
134 Initiates an SDO download service. `<multiplexer>` is a combination of an object
135 index and sub-index, while `<datatype>` must be one of the values in the table
136 above.
137 
138 ### Configure SDO time-out
139 
140  [net] set sdo_timeout <value>
141 
142 Configures the time-out (in milliseconds) for all client-SDOs on the gateway.
143 The actual time-out used is limited by the value set with `set command_timeout`.
144 
145 PDO access services
146 -------------------
147 
148 ### Configure RPDO
149 
150  [net] set rpdo <nr> <COB> <tx-type> <nr-of-data> <map-obj1>[..<map-obj64>]
151 
152 where
153 
154  <tx-type> ::= "rtr" | "event" | "sync<0..240>"
155 
156 is the transmission type.
157 
158 Creates an RPDO on the gateway. `<nr-of-data>` specifies the number of
159 `<map-obj>` values, each of which is an object index and sub-index (i.e., a
160 `<multiplexer>`). Dummy mappings can be created by specifying the object index
161 of one of the static data types (in the range [0x0001..0x001F]).
162 
163 ### Simple configure TPDO
164 
165  [net] set tpdo <nr> <COB> <tx-type> <nr-of-data> <map-obj1>[..<map-obj64>]
166 
167 where
168 
169  <tx-type> ::= "rtr" | "event" | "sync<0..240>"
170 
171 is the transmission type.
172 
173 Creates a TPDO on the gateway. `<nr-of-data>` specifies the number of
174 `<map-obj>` values, each of which is an object index and sub-index (i.e., a
175 `<multiplexer>`).
176 
177 ### Extended configure TPDO
178 
179  [net] set tpdox <nr> <COB> <tx-type> <nr-of-data> <map-obj1>[..<map-obj64>]
180 
181 where
182 
183  <tx-type> ::= "rtr" | "event<intime> <etime>" | "sync<0..240> <scount>"
184 
185 is the transmission type.
186 
187 Similar to the `set tpdo` command, but allows the configuration of the inhibit
188 time (`<intime>`) and event time (`<etime>`), both in milliseconds, and the SYNC
189 start value (`<scount>`).
190 
191 ### Read PDO data
192 
193  [net] r[ead] p[do] <nr>
194 
195 Reads the values of the mapped objects of an RPDO.
196 
197 Note that this implementation does not support the RTR transmission type.
198 
199 ### Write PDO data
200 
201  [net] w[rite] p[do] <nr> <nr-of-data> <value1>[..<value64>]
202 
203 Writes the values to the mapped objects of a TPDO and triggers its transmission.
204 
205 CANopen NMT services
206 --------------------
207 
208 With the exception of heartbeat consumption, NMT services are only available on
209 a class 3 gateway, which acts as the CANopen manager.
210 
211 ### Start node
212 
213  [[net] node] start
214 
215 Sets the specified slave to the NMT state operational. If `node` is 0, all
216 slaves are affected.
217 
218 ### Stop node
219 
220  [[net] node] stop
221 
222 Sets the specified slave to the NMT state stopped. If `node` is 0, all slaves
223 are affected.
224 
225 ### Set node to pre-operational
226 
227  [[net] node] preop[erational]
228 
229 Sets the specified slave to the NMT state pre-operational. If `node` is 0, all
230 slaves are affected.
231 
232 ### Reset node
233 
234  [[net] node] reset node
235 
236 Sets the specified slave to the NMT state reset application. If `node` is 0, all
237 slaves are affected.
238 
239 ### Reset communication
240 
241  [[net] node] reset comm[unication]
242 
243 Sets the specified slave to the NMT state communication. If `node` is 0, all
244 slaves are affected.
245 
246 ### Enable node guarding
247 
248  [[net] node] enable guarding <guardingtime> <lifetimefactor>
249 
250 Starts node guarding for the specified slave. `<guardingtime>` is specified in
251 milliseconds. If `<guardingtime>` or `<lifetimefactor>` is 0, node guarding is
252 disabled.
253 
254 ### Disable node guarding
255 
256  [[net] node] disable guarding
257 
258 Stops node node guarding for the specified slave.
259 
260 ### Start heartbeat consumer
261 
262  [[net] node] enable heartbeat <heartbeat_consumer_time>
263 
264 Starts the consumption of heartbeat messages for the specified slave.
265 `<heartbeat_consumer_time>` is specified in milliseconds. A value of 0 disables
266 heartbeat consumption.
267 
268 ### Disable heartbeat consumer
269 
270  [[net] node] disable heartbeat
271 
272 Stops the consumption of heartbeat messages for the specified slave.
273 
274 CANopen interface configuration services
275 ----------------------------------------
276 
277 ### Initialize gateway
278 
279  [net] init <bitrate>
280 
281 Initializes the bit rate of the gateway and performs a power-on equivalent reset
282 of the CANopen interface. `<bitrate>` must be one of the valid table_index
283 values specified in the bit-rates table.
284 
285 ### Set heartbeat producer
286 
287  [net] set heartbeat <value>
288 
289 Sets the heartbeat producer time (in milliseconds) of the gateway. A value of 0
290 disables heartbeat production.
291 
292 ### Set node-ID
293 
294  [net] set id <value>
295 
296 Sets the pending node-ID of the gateway.
297 
298 ### Set command time-out
299 
300  [net] set command_timeout <value>
301 
302 Sets the maximum allowed duration (in milliseconds) for processing a command.
303 
304 Note that in this implementation the time-out applies to a single SDO or LSS
305 response, _not_ the overall duration of a command.
306 
307 ### Boot-up forwarding
308 
309  [net] boot_up_indication <cs>
310 
311 where
312 
313  <cs> ::= "Enable" | "Disable"
314 
315 Enables or disables the forwarding of "boot-up message received" events.
316 
317 Gateway management services
318 ---------------------------
319 
320 ### Set default network
321 
322  set network <value>
323 
324 Sets the default network number to be used for all services.
325 
326 ### Set default node-ID
327 
328  [net] set node <value>
329 
330 Sets the default node-ID to be used for all services.
331 
332 ### Get version
333 
334  [net] info version
335 
336 Returns information on the gateway and its CANopen interface.
337 
338 ### Set command size
339 
340  set command_size <value>
341 
342 Sets the maximum size (in bytes) of a command to be accepted by the gateway.
343 
344 Note that this command is implemented but will always return an error since we
345 cannot make any guarantees about memory resources.
346 
347 Layer setting services
348 ----------------------
349 
350 Layer setting services (LSS) are only available on a class 3 gateway, which acts
351 as the CANopen manager.
352 
353 ### LSS switch state global
354 
355  [net] lss_switch_glob <0|1>
356 
357 Switches all slaves to the waiting (0) or configuration (1) state.
358 
359 ### LSS switch state selective
360 
361  [net] lss_switch_sel <vendorID> <product code> <revisionNo> <serialNo>
362 
363 Switches the slave with the specified LSS address to the configuration state.
364 
365 ### LSS configure node-ID
366 
367  [net] lss_set_node <node>
368 
369 Configures the pending node-ID of the slave that is in the configuration state.
370 
371 ### LSS configure bit-rate
372 
373  [net] lss_conf_bitrate <table_selector> <table_index>
374 
375 Configures the new pending bit rate of the slave that is in the configuration
376 state. `<table_selector>` must be 0, while `<table_index>` must be one of the
377 values in the bit-rates table.
378 
379 ### LSS activate new bit-rate
380 
381  [net] lss_activate_bitrate <switch_delay>
382 
383 Activates simultaneously the bit rate of all CANopen devices in the network,
384 where `<switch_delay>` specifies the length (in milliseconds) of two delay
385 periods of equal length. Each slaves waits one period before switching the
386 pending bit rate to the active bit rate, then waits another period before
387 transmitting any messages.
388 
389 ### LSS store configuration
390 
391  [net] lss_store
392 
393 Requests the slave to store the configured local layer settings to non-volatile
394 memory.
395 
396 ### Inquire LSS address
397 
398  [net] lss_inquire_addr <Code>
399 
400 Requests an LSS number from the slave that is in the configuration state, where
401 
402  <Code> ::= "0x5A" | "0x5B" | "0x5C" | "0x5D"
403 
404 is the code for the vendor-ID, product code, revision number and serial number,
405 respectively.
406 
407 ### LSS inquire node-ID
408 
409  [net] lss_get_node
410 
411 Requests the active node-ID of the slave that is in the configuration state.
412 
413 ### LSS identify remote slave
414 
415  [net] lss_identity <vendorID> <product code> <revisionNo_low> \
416  <revisionNo_high> <serialNo_low> <serialNo_high>
417 
418 Checks if a slave exists with the specified vendor-ID and product code, and a
419 revision number and serial number within the specified range.
420 
421 ### LSS identify non-configured remote slaves command
422 
423  [net] lss_ident_nonconf
424 
425 Checks if there are any slaves with an invalid node-ID (0xff/255).
426 
427 ### LSS Slowscan (Lely specific)
428 
429  [net] _lss_slowscan <vendorID> <product code> <revisionNo_low> \
430  <revisionNo_high> <serialNo_low> <serialNo_high>
431 
432 Performs a binary search using `lss_identity` to identify a single slave with an
433 LSS address in the specified range. On success, the slave is switched to the
434 configuration state with `lss_switch_sel`.
435 
436 Because this is an aggregate command, it may take longer to complete than the
437 time set with `set command_timeout`.
438 
439 ### LSS Fastscan (Lely specific)
440 
441  [net] _lss_fastscan <vendorID> <vendorID mask> <product code> \
442  <product code mask> <revisionNo> <revisionNo mask> \
443  <serialNo> <serialNo mask>
444 
445 Uniquely identifies a single slave by repeatedly employing the LSS Fastscan
446 service. On success, the slave is switch to the configuration state. For each
447 LSS number the user supplies a value with the known bits and a mask identifying
448 which bits are known.
449 
450 Because this is an aggregate command, it may take longer to complete than the
451 time set with `set command_timeout`.
452 
453 Example
454 -------
455 
456 A typical session may look like:
457 
458  $ coctl can0 /etc/coctl.dcf
459  > [1] set network 1 # Set the default network, so it can be omitted.
460  < [1] OK
461  > [2] set id 1 # Set the node-ID of the gateway to 1.
462  < [2] OK
463  > [3] init 0 # Initialize the gateway, and configure to CAN bus
464  > [3] # with a bit rate of 1000 kbit/s.
465  < [3] OK
466  < 1 2 BOOT_UP
467  < 1 2 USER BOOT A (The CANopen device is not listed in object 1F81.)
468  > [4] set node 2 # Target the slave with node-ID 2.
469  < [4] OK
470  > [5] r 0x1018 0x01 u32 # Read the vendor-ID (sub-object 1018:01).
471  < [5] 0x00000360 # A device by Lely Industries N.V.
472