CiA Draft Standard 309
CANopen
Interfacing CANopen with TCP/IP
Part 3: ASCII mapping
Version 1.1
12 December 2006
© CAN in Automation (CiA) e. V.
CiA 309-2
Interfacing CANopen with TCP/IP - Part 2: Modbus/TCP mapping
Version 1.1
HISTORY
Date
2004-09-15
2006-12-12
Changes
Publication of version 1.0 as draft standard proposal
Publication of version 1.1 as draft standard
Minor editorial corrections and clarifications.
General information on licensing and patents
CAN in AUTOMATION (CiA) calls attention to the possibility that some of the elements of this CiA
specification may be subject of patent rights. CiA shall not be responsible for identifying any or all
such patent rights.
Because this specification is licensed free of charge, there is no warranty for this specifica-
tion, to the extent permitted by applicable law. Except when otherwise stated in writing the
copyright holder and/or other parties provide this specification “as is” without warranty of
any kind, either expressed or implied, including, but not limited to, the implied warranties of
merchantability and fitness for a particular purpose. The entire risk as to the correctness
and completeness of the specification is with you. Should this specification prove failures,
you assume the cost of all necessary servicing, repair or correction.
© CiA 2008
All rights reserved. Unless otherwise specified, no part of this publication may be reproduced or
utilized in any form or by any means, electronic or mechanical, including photocopying and micro-
film, without permission in writing from CiA at the address below.
CAN in Automation e. V.
Kontumazgarten 3
DE - 90429 Nuremberg, Germany
Tel.: +49-911-928819-0
Fax: +49-911-928819-79
Url: www.can-cia.org
Email: headquarters@can-cia.org
2
© CiA 2008 - All rights reserved
CiA 309-3
Interfacing CANopen with TCP/IP – Part 3: ASCII mapping
Version 1.1
Contents
1 Scope...................................................................................................................................................5
2 References ..........................................................................................................................................5
3 Abbreviations and definitions.............................................................................................................5
3.1 Abbreviations ...............................................................................................................................5
3.2 Definitions.....................................................................................................................................5
3.2.1 General..................................................................................................................................5
3.2.2 Command structure ..............................................................................................................6
4 Network access command specification ...........................................................................................8
4.1 SDO access commands..............................................................................................................8
4.1.1 General..................................................................................................................................8
4.1.2 Upload SDO command ........................................................................................................8
4.1.3 Download SDO command ...................................................................................................8
4.1.4 Configure SDO timeout command ......................................................................................9
4.2 PDO access commands..............................................................................................................9
4.2.1 General..................................................................................................................................9
4.2.2 Configure RPDO command .................................................................................................9
4.2.3 Configure TPDO command..................................................................................................9
4.2.4 Read PDO data command................................................................................................ 10
4.2.5 Write PDO data command ................................................................................................ 10
4.2.6 RPDO received command ................................................................................................ 10
4.3 CANopen NMT commands ...................................................................................................... 10
4.3.1 General............................................................................................................................... 10
4.3.2 Start node command ......................................................................................................... 10
4.3.3 Stop node command ......................................................................................................... 10
4.3.4 Set node to pre-operational command............................................................................. 10
4.3.5 Reset node command ....................................................................................................... 11
4.3.6 Reset communication command ...................................................................................... 11
4.3.7 Enable node guarding command...................................................................................... 11
4.3.8 Disable node guarding command..................................................................................... 11
4.3.9 Start heartbeat consumer command................................................................................ 11
4.3.10 Disable heartbeat consumer command ......................................................................... 11
4.3.11 Error control event received command .......................................................................... 11
4.4 Device failure management commands.................................................................................. 12
4.4.1 General............................................................................................................................... 12
4.4.2 Read device error command ............................................................................................ 12
4.4.3 Emergency event received command.............................................................................. 12
4.5 CANopen interface configuration commands ......................................................................... 12
4.5.1 General............................................................................................................................... 12
4.5.2
Initialize gateway command.............................................................................................. 12
4.5.3 Store configuration command........................................................................................... 12
4.5.4 Restore configuration command....................................................................................... 13
© CiA 2008 - All rights reserved
3
CiA 309-2
Interfacing CANopen with TCP/IP - Part 2: Modbus/TCP mapping
Version 1.1
4.5.5 Set heartbeat producer command.................................................................................... 13
4.5.6 Set node-ID command ...................................................................................................... 13
4.5.7 Start emergency consumer command ............................................................................. 13
4.5.8 Stop emergency consumer command ............................................................................. 13
4.6 Gateway management commands.......................................................................................... 13
4.6.1 General............................................................................................................................... 13
4.6.2 Set default network command .......................................................................................... 13
4.6.3 Set default node-ID command.......................................................................................... 13
4.6.4 Get version command ....................................................................................................... 13
4.7 Controller management commands ........................................................................................ 14
4.7.1 General............................................................................................................................... 14
4.7.2 Reset controller command ................................................................................................ 14
4.7.3 Start controller command .................................................................................................. 14
4.7.4 Stop controller command .................................................................................................. 14
4.8 Manufacturer-specific commands............................................................................................ 14
4.8.1 General............................................................................................................................... 14
4
© CiA 2008 - All rights reserved
CiA 309-3
Interfacing CANopen with TCP/IP – Part 3: ASCII mapping
Version 1.1
1 Scope
This specification specifies the services and protocols to interface CANopen networks to a TCP/IP-
based network.
This set of specifications is organized as follows:
• Part 1: General principles and services
• Part 2: Modbus/TCP mapping
• Part 3: ASCII mapping
This part of the specification defines the ASCII-based communication syntax for CANopen gateway
devices. The aim is to provide a lightweight counterpart to solutions with CORBA or OPC.
2 References
The references given in part 1 shall apply to this part, too.
7CiA301/
/CiA309-1/
CiA 301, CANopen application layer and communication profile
CiA 309:2006, Interfacing CANopen with TCP/IP – Part 1: General principles and
services (V1.1)
ISO/IEC 646, 1991 Information technology – ISO 7-bit coded character set for in-
formation interchange
/ISO/IEC 646/
/ISO/IEC 9899/ ISO/IEC 9899, 1999
/RFC 2045/
RFC 2045 Multipurpose internet mail extensions
Programming languages – C
3 Abbreviations and definitions
3.1 Abbreviations
The abbreviations given in part 1 shall apply to this part, too.
ASCII
BNF
CPU
CR
CRLF
LF
American Standard Code for Information Interchange
Backus Naur form
Central Processing Unit
Carriage Return
Carriage Return and Line Feed
Line Feed
3.2 Definitions
3.2.1 General
The definitions given in part 1 shall apply to this part, too.
Command
controls the gateway and interacts with CANopen devices. It may have a long form and a short
form. The short form is a one or two letter abbreviation of the long form. The long form is obtained
by concatenating the short form and the string enclosed in brackets “[“, “]”.
Note: In the given examples it is assumed that network address and node address are preset.
Data type syntax
The mandatory data types shall be supported.
Table 1: Syntax and CANopen data types
Syntax
b
u8
u16
CANopen Type
Boolean
Unsigned8
Unsigned16
Category
Mandatory
Mandatory
Mandatory
© CiA 2008 - All rights reserved
5
CiA 309-2
Interfacing CANopen with TCP/IP - Part 2: Modbus/TCP mapping
Version 1.1
Syntax
u24
u32
u40
u48
u56
u64
i8
i16
i24
i32
i40
i48
i56
i64
r32
r64
t
td
vs
os
us
d
CANopen Type
Unsigned24
Unsigned32
Unsigned40
Unsigned48
Unsigned56
Unsigned64
Integer8
Integer16
Integer24
Integer32
Integer40
Integer48
Integer56
Integer64
Real32
Real64
Time of day (with two arguments: day ms)
Time difference
Visible string
Octet string
Unicode string
Domain
Category
Optional
Mandatory
Optional
Optional
Optional
Optional
Mandatory
Mandatory
Optional
Mandatory
Optional
Optional
Optional
Optional
Optional
Optional
Optional
Optional
Optional
Optional
Optional
Optional
The value of the data type domain, octet string, and unicode string shall be encoded in mime-
base64 as specified in /RFC 2045/. All wrapping CRLF shall be stripped from the encoded data to
have one long string.
whitespace
As specified in /ISO/IEC 9899/ except of CR and LF.
Note: A visible string with whitespace is enclosed with double quotes to denote it as single argu-
ment of the command. If a double quote is used within the string, the quotes are escaped by a sec-
ond quotes, e.g. “Hello “”World””, CANopen is great”.
3.2.2 Command structure
The principle communication is based on non-case-sensitive ASCII strings /ISO/IEC 646/ instead of
architecture and CPU/compiler depending binary structures. Due to this, no application handles
with things like endianness, data size and byte alignment. In all cases where numbers are used,
the typical representation like specified in /ISO/IEC 9899/.
- decimal, starting with a number
- hexadecimal, starting with the string 0x
- float
- float
- float
100
0x64
1.22
.22e10
22e3
3.2.2.1 Request
The CANopen gateway is controlled by commands. A command is composed of tokens, which are
separated by any number of whitespaces and is closed with a CRLF.
6
© CiA 2008 - All rights reserved
CiA 309-3
Interfacing CANopen with TCP/IP – Part 3: ASCII mapping
Version 1.1
All commands are confirmed. Commands start with a sequence number which is enclosed by
square brackets [ ]. The sequence number is a 4-byte value. It is not used for event-triggered mes-
sages. According to the addressing principle, a network number and a node number follow the
sequence number. Network number and node number are optional, when the CANopen gateway
only provides one Ethernet/CAN interface or when a client presets them. Commands that affect
only the server not a remote node but a net and node are given net and node are ignored. In BNF
notation a command defines as follows:
::= "[""]" [[] ]
::= UNSIGNED32
::= UNSIGNED8
::= UNSIGNED8
::= |
::=
::= |
::=
::= |
::= ‘b’ | ‘u8’ | ‘u16’ | ‘u32’ | ‘u40’ | ‘u48’ |
‘u56’ | ‘u64’ | ‘i8’ | ‘i16’ | ‘i24’ | ‘i32’ |
‘i40’ | ‘i48’ | ‘i56’ | ‘i64’ | ‘r32’ | ‘r64’ |
‘t’ | ‘td’ | ‘vs’ | ‘os’ | ‘us’ | ‘d’
::=
::= UNSIGNED16
::= UNSIGNED8
Net numbers are starting with 1. Node numbers are starting with 1. The value 0 for net or node is
used to address all networks or all nodes.
The token designates a value of the possible CANopen data types.
Within the description of the commands the sequence number is omitted for reasons of readability.
3.2.2.2 Response
The CANopen gateway shall respond with the same sequence number at the first position as given
by the request. This number shall be given in decimal format. There shall be only one response to
a request.
::= "[""]"
| "OK"
::= | |
::= "Error:"
::= |
::= see table 2
::= UNSIGNED32
::= [ " "..]
The sdo-abort-codes (SAC) are defined in /CiA301/. Allowed internal-error-codes (IEC) are listed in
Table 2:
Table 2 - Internal error code
IEC Message text
100
101
102
Request not supported
Syntax error
Request not processed due to internal state
© CiA 2008 - All rights reserved
7
CiA 309-2
Interfacing CANopen with TCP/IP - Part 2: Modbus/TCP mapping
Version 1.1
103
200
201
202
203
205
300
301
303
304
305
400
401
Time-out (where applicable)
Lost guarding message
Lost connection
Heartbeat started
Heartbeat lost
Boot-up
Error passive
Bus off
CAN buffer overflow
CAN init
CAN active (at init or start-up)
PDO already used
PDO length exceeded
Note: After bus-off, the command init should be invoked to reset the CAN controller.
3.2.2.3 Event triggered messages
Messages due to errors in the CANopen network or the occurrence of communication objects using
the producer-consumer principle shall not use a sequence number.
::= [[net] node]
::= "EMCY" | "ERROR" | "PDO" | "SYNC" | "USER"
The content of event-triggered messages is described within the command description that enables
the specific service.
4 Network access command specification
4.1 SDO access commands
4.1.1 General
The following command definitions shall be used to implement the SDO access services as defined
in part 1.
SDO access services are addressing a specific object at an SDO server via index and sub-index
and a transfer data type.
4.1.2 Upload SDO command
Indication syntax:
[[net] node] r[ead]
Examples:
[21] r 0x1000 0 u32
[4096] read 0x1008 0 vs
See chapter 3.2.2.2
Response syntax:
4.1.3 Download SDO command
Indication syntax:
[[net] node] w[rite]
Examples:
[20] 1 23 w 0x1016 0 u16 100
8
© CiA 2008 - All rights reserved