CAN@net NT 200/420 Generic Protocol for Gateway Mode SOFTWARE DESIGN GUIDE 4.02.0332.20000 1.
Important User Information Liability Every care has been taken in the preparation of this document. Please inform HMS Industrial Networks of any inaccuracies or omissions. The data and illustrations found in this document are not binding. We, HMS Industrial Networks, reserve the right to modify our products in line with our policy of continuous product development. The information in this document is subject to change without notice and should not be considered as a commitment by HMS Industrial Networks.
Table of Contents 1 Page User Guide ........................................................................................................................... 3 1.1 Related Documents ..........................................................................................................3 1.2 Document History ............................................................................................................3 1.3 Trademark Information ........................................................
This page intentionally left blank
User Guide 1 3 (26) User Guide Please read the manual carefully. Make sure you fully understand the manual before using the product. 1.1 1.2 1.3 Related Documents Document Author Installation Guide VCI Driver HMS User Manual CAN@net NT HMS Document History Version Date Description 1.0 June 2016 First release 1.1 October 2016 Adjusted filter examples in 4.2 CAN commands 1.2 July 2017 Added information about CAN@net NT 420 1.3 April 2018 Adjusted PING REQUEST and title 1.
User Guide 1.4 4 (26) Conventions Instructions and results are structured as follows: ► instruction 1 ► instruction 2 → result 1 → result 2 Lists are structured as follows: • item 1 • item 2 Bold typeface indicates interactive parts such as connectors and switches on the hardware, or menus and buttons in a graphical user interface. This font is used to indicate program code and other kinds of data input/output such as configuration scripts.
TCP Server Function 2 5 (26) TCP Server Function In the Gateway mode the device is acting as a TCP server and transmits and receives data on the TCP port that is defined with the CAN-Gateway Configurator. The default TCP port is 19228. Connection: • Server exclusively accepts a single connection. • Additional connection requests are rejected. • Server exchanges data and commands with the ASCII protocol.
ASCII Protocol 3 6 (26) ASCII Protocol The ASCII protocol is used to pack data (CAN messages) and commands for the transfer over Ethernet TCP/IP network. The ASCII-Protocol in Version 2.0 supports 6 different message types: • Messages (both directions) • CAN Commands (from client to server) • Device Commands (from client to server) • Events (from server to client) • Responses (from server to client) • Ping Request Commands have to be confirmed.
Message Types 7 (26) 4 Message Types 4.1 Message Used to exchange CAN messages between the device and the Ethernet TCP/IP host and to exchange information in both directions, to and from the device. When a device receives a message on the CAN bus: • CAN message is packed into an ASCII protocol message of type Message and transmitted over Ethernet TCP/IP. When device receives an ASCII-Protocol message of type Message from Ethernet TCP/IP: • Message is unpacked and translated into a CAN message.
Message Types 4.2 8 (26) Cyclic Message With the cyclic messages commands it is possible to send CAN messages from the CAN@net NT cyclically, precisely timed and with high frequency, whereas the application data must only be updated by ASCII commands if required. • up to 16 cyclic messages are possible • configuration only via ASCII command • each message can be configured and the transmission started and stopped individually Valid Order of Use 4.2.
Message Types 4.2.2 9 (26) CYC UPDATE Starts the transmission of an initialized cyclic message and updates the cyclic message . The command can only be executed if the message is initialized. CYC UPDATE Parameter Parameter msg_num can-message Description Message number, valid values: 0–15. Message must be initialized. Updated CAN message, for information about the message format see Message, p. 7. Specify value 0 for the port.
Message Types 4.3 10 (26) CAN Commands Fig. 1 CAN states The commands that are used to control the CAN controller on the device and to modify the settings of filter table are described in the following chapters. Valid Order of Use ► Stop the CAN controller (see Stopping the CAN Controller, p. 16). ► Initialize the CAN controller (see Initializing the CAN Controller, p. 11). → Filter settings are deleted and all messages are rejected. ► Configure the filter (see Configuring the Filter, p. 14).
Message Types 4.3.1 11 (26) Initializing the CAN Controller Make sure, the CAN controller is not in running state before initialization. With the initialization the CAN controller loses its filter settings and all messages are rejected. Configure the filter after initialization. CAN INIT Initializes the CAN controller with the baud rate value.
Message Types 12 (26) CAN INIT CUSTOM Initializes the CAN controller with user defined baud rates via register values for brp, sjw, tseg1 and tseg2. For CAN FD values tdo and iso must additionally be set, as well as all register values for the data phase. If customized register values are used, check in CAN-Gateway Configurator if the values result in a usable baud rate.
Message Types 13 (26) CAN INIT AUTO Automatic baud rate detection is only possible with Classic CAN. CAN FD does not support automatic baud rate detection. Starts the automatic baud rate detection. The CAN controller tries to auto detect a baud rate on the bus, based on the following possible baud rates in kBd: 5, 10, 20, 50, 100, 125, 250, 500, 800, 1 000. If a baud rate is detected the controller is initialized.
Message Types 4.3.2 14 (26) Configuring the Filter Make sure, that the CAN controller is in stopped state before configuring the filter. CAN FILTER CLEAR Deletes all filter entries for 11 and 29 bit identifiers. CAN FILTER CLEAR Parameter Parameter Description port CAN port number 1...2 (with NT 200), 1...4 (with NT 420) Example CAN 1 FILTER CLEAR Return Value Return value R ok R ERR Description Function succeeded See List of Error Codes, p.
Message Types 15 (26) Parameter Parameter Description port CAN port number 1...2 (with NT 200), 1...4 (with NT 420) type Message format type: STD or EXT identifier Value for the identifier to match (in HEX) mask Value for the mask (in HEX) Example CAN 1 FILTER ADD STD 100 700 Return Value Return value R ok R ERR Description Function succeeded See List of Error Codes, p.
Message Types 4.3.3 16 (26) Starting the CAN Controller Sets the CAN controller in running state. CAN START Parameter Parameter Description port CAN port number 1...2 (with NT 200), 1...4 (with NT 420) Example CAN 1 START Return Value Description Return value R ok Function succeeded R ERR See List of Error Codes, p. 24 4.3.4 Stopping the CAN Controller Sets the CAN controller in stopped state for (re-)configuration.
Message Types 4.3.5 17 (26) Requesting the Status CAN status responses always include the CAN channel number. CAN STATUS Reads the CAN status value. Can only be used in stopped and in running state. CAN STATUS Parameter Parameter Description port CAN port number 1...2 (with NT 200), 1...4 (with NT 420) Example CAN 1 STATUS Return Value The command CAN Status returns CAN status information. R CAN port CAN port number 1...2 (with NT 200), 1...
Message Types 18 (26) CAN STATUS AUTO Reads the CAN baud rate detection status. CAN STATUS AUTO Parameter Parameter Description port CAN port number 1...2 (with NT 200), 1...
Message Types 4.4 19 (26) Device Commands The ASCII protocol supports the following DEV (device) commands: 4.4.1 • DEV IDENTIFY • DEV VERSION • DEV PROTOCOL • DEV INTERFACES DEV IDENTIFY Identifies the device. DEV IDENTIFY Return Value Return value Description R CAN@net NT 420 Identity of the device R ERR See List of Error Codes, p. 24 4.4.2 DEV VERSION Reads the firmware version number of the device. DEV VERSION Return Value Description Return value R V1.
Message Types 4.5 20 (26) Events The following events are transmitted to the host if the CAN controller changes the status. E ERRORWARNING SET CAN controller reached Error Warning level. E ERRORWARNING RESET CAN controller under-run Error Warning level. E BUSOFF CAN controller reached Bus Off state. The error status of the CAN controller and the error counter are defined according to ISO 118981:2015. 4.6 Responses 4.6.1 Positive Response A positive response is always R ok.
Message Types 4.7 21 (26) PING REQUEST Monitors the connection between host and CAN@net NT (heartbeat mechanism). The CAN@net NT answers to a PING REQUEST with a PING RESPONSE. The first PING REQUEST activates the connection monitoring. If no further PING REQUEST is received in the defined time (set in parameter timeout in seconds, default value are 3 seconds), the CAN@net NT is disconnected and reset. PING REQUEST Parameter Timeout in seconds (1...
How to Handle Incoming Messages 5 22 (26) How to Handle Incoming Messages The communication from and to the device is handled asynchronous. Example A CAN status command/response sequence can be interrupted by incoming CAN messages. tx: rx: rx: rx: CAN 1 STATUS M 1 CSD 123 02 22 33 M 2 CSD 345 02 55 AA R CAN 1 ----- 100 This is especially the case when working with more than one CAN controller.
Example 6 23 (26) Example The following example shows an initialization of both CAN channels. The direction is shown by rx. (transmitted by user) and tx. (received by user). tx: DEV VERSION rx: R V0.10.
List of Error Codes 7 24 (26) List of Error Codes Error number Error description 0 Unknown error ‘’ 1 CAN baud rate not found 2 CAN stop failed 3 CAN start failed 4 CAN extended filter is full 5 CAN standard open filter set twice 6 CAN standard filter is full 7 CAN invalid identifier or mask for filter add 8 CAN baud rate detection is busy 9 CAN invalid parameter type 10 C
This page intentionally left blank
last page © 2019 HMS Industrial Networks Box 4126 300 04 Halmstad, Sweden info@hms.se 4.02.0332.20000 1.