1 coctl - CANopen control tool
2 ============================
9 coctl [-e | --exit] [-i ms | --inhibit=ms] [-m | --monitor] [-W | --no-wait]
10 [interface filename]...
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).
18 The options are as follows:
20 -e, --exit Exit on error.
21 -h, --help Display help.
22 -i <ms>, --inhibit=<ms>
23 Wait at least <ms> milliseconds between requests
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.
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.
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].
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").
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.
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.
56 Some SDO and PDO commands require data type indications. The data type syntax is
57 provided in the following table:
59 Syntax | CANopen data type
60 ------ | -----------------
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]).
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:
103 table_index | Bit rate
104 ----------- | ----------------------------
114 9 | Automatic bit rate detection
116 [ISO/IEC 9899]: http://www.open-std.org/jtc1/sc22/wg14/www/standards.html
117 [RFC 2045]: https://tools.ietf.org/html/rfc2045
124 [[net] node] r[read] <multiplexer> <datatype>
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
132 [[net] node] w[rite] <multiplexer> <datatype> <value>
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
138 ### Configure SDO time-out
140 [net] set sdo_timeout <value>
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`.
150 [net] set rpdo <nr> <COB> <tx-type> <nr-of-data> <map-obj1>[..<map-obj64>]
154 <tx-type> ::= "rtr" | "event" | "sync<0..240>"
156 is the transmission type.
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]).
163 ### Simple configure TPDO
165 [net] set tpdo <nr> <COB> <tx-type> <nr-of-data> <map-obj1>[..<map-obj64>]
169 <tx-type> ::= "rtr" | "event" | "sync<0..240>"
171 is the transmission type.
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
177 ### Extended configure TPDO
179 [net] set tpdox <nr> <COB> <tx-type> <nr-of-data> <map-obj1>[..<map-obj64>]
183 <tx-type> ::= "rtr" | "event<intime> <etime>" | "sync<0..240> <scount>"
185 is the transmission type.
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>`).
193 [net] r[ead] p[do] <nr>
195 Reads the values of the mapped objects of an RPDO.
197 Note that this implementation does not support the RTR transmission type.
201 [net] w[rite] p[do] <nr> <nr-of-data> <value1>[..<value64>]
203 Writes the values to the mapped objects of a TPDO and triggers its transmission.
208 With the exception of heartbeat consumption, NMT services are only available on
209 a class 3 gateway, which acts as the CANopen manager.
215 Sets the specified slave to the NMT state operational. If `node` is 0, all
222 Sets the specified slave to the NMT state stopped. If `node` is 0, all slaves
225 ### Set node to pre-operational
227 [[net] node] preop[erational]
229 Sets the specified slave to the NMT state pre-operational. If `node` is 0, all
234 [[net] node] reset node
236 Sets the specified slave to the NMT state reset application. If `node` is 0, all
239 ### Reset communication
241 [[net] node] reset comm[unication]
243 Sets the specified slave to the NMT state communication. If `node` is 0, all
246 ### Enable node guarding
248 [[net] node] enable guarding <guardingtime> <lifetimefactor>
250 Starts node guarding for the specified slave. `<guardingtime>` is specified in
251 milliseconds. If `<guardingtime>` or `<lifetimefactor>` is 0, node guarding is
254 ### Disable node guarding
256 [[net] node] disable guarding
258 Stops node node guarding for the specified slave.
260 ### Start heartbeat consumer
262 [[net] node] enable heartbeat <heartbeat_consumer_time>
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.
268 ### Disable heartbeat consumer
270 [[net] node] disable heartbeat
272 Stops the consumption of heartbeat messages for the specified slave.
274 CANopen interface configuration services
275 ----------------------------------------
277 ### Initialize gateway
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.
285 ### Set heartbeat producer
287 [net] set heartbeat <value>
289 Sets the heartbeat producer time (in milliseconds) of the gateway. A value of 0
290 disables heartbeat production.
296 Sets the pending node-ID of the gateway.
298 ### Set command time-out
300 [net] set command_timeout <value>
302 Sets the maximum allowed duration (in milliseconds) for processing a command.
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.
307 ### Boot-up forwarding
309 [net] boot_up_indication <cs>
313 <cs> ::= "Enable" | "Disable"
315 Enables or disables the forwarding of "boot-up message received" events.
317 Gateway management services
318 ---------------------------
320 ### Set default network
324 Sets the default network number to be used for all services.
326 ### Set default node-ID
328 [net] set node <value>
330 Sets the default node-ID to be used for all services.
336 Returns information on the gateway and its CANopen interface.
340 set command_size <value>
342 Sets the maximum size (in bytes) of a command to be accepted by the gateway.
344 Note that this command is implemented but will always return an error since we
345 cannot make any guarantees about memory resources.
347 Layer setting services
348 ----------------------
350 Layer setting services (LSS) are only available on a class 3 gateway, which acts
351 as the CANopen manager.
353 ### LSS switch state global
355 [net] lss_switch_glob <0|1>
357 Switches all slaves to the waiting (0) or configuration (1) state.
359 ### LSS switch state selective
361 [net] lss_switch_sel <vendorID> <product code> <revisionNo> <serialNo>
363 Switches the slave with the specified LSS address to the configuration state.
365 ### LSS configure node-ID
367 [net] lss_set_node <node>
369 Configures the pending node-ID of the slave that is in the configuration state.
371 ### LSS configure bit-rate
373 [net] lss_conf_bitrate <table_selector> <table_index>
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.
379 ### LSS activate new bit-rate
381 [net] lss_activate_bitrate <switch_delay>
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.
389 ### LSS store configuration
393 Requests the slave to store the configured local layer settings to non-volatile
396 ### Inquire LSS address
398 [net] lss_inquire_addr <Code>
400 Requests an LSS number from the slave that is in the configuration state, where
402 <Code> ::= "0x5A" | "0x5B" | "0x5C" | "0x5D"
404 is the code for the vendor-ID, product code, revision number and serial number,
407 ### LSS inquire node-ID
411 Requests the active node-ID of the slave that is in the configuration state.
413 ### LSS identify remote slave
415 [net] lss_identity <vendorID> <product code> <revisionNo_low> \
416 <revisionNo_high> <serialNo_low> <serialNo_high>
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.
421 ### LSS identify non-configured remote slaves command
423 [net] lss_ident_nonconf
425 Checks if there are any slaves with an invalid node-ID (0xff/255).
427 ### LSS Slowscan (Lely specific)
429 [net] _lss_slowscan <vendorID> <product code> <revisionNo_low> \
430 <revisionNo_high> <serialNo_low> <serialNo_high>
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`.
436 Because this is an aggregate command, it may take longer to complete than the
437 time set with `set command_timeout`.
439 ### LSS Fastscan (Lely specific)
441 [net] _lss_fastscan <vendorID> <vendorID mask> <product code> \
442 <product code mask> <revisionNo> <revisionNo mask> \
443 <serialNo> <serialNo mask>
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.
450 Because this is an aggregate command, it may take longer to complete than the
451 time set with `set command_timeout`.
456 A typical session may look like:
458 $ coctl can0 /etc/coctl.dcf
459 > [1] set network 1 # Set the default network, so it can be omitted.
461 > [2] set id 1 # Set the node-ID of the gateway to 1.
463 > [3] init 0 # Initialize the gateway, and configure to CAN bus
464 > [3] # with a bit rate of 1000 kbit/s.
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.
470 > [5] r 0x1018 0x01 u32 # Read the vendor-ID (sub-object 1018:01).
471 < [5] 0x00000360 # A device by Lely Industries N.V.