Protocol

Session

Communication is initiated by a computer program, by establishing a session with the TCP port (default 61235) of the XnTcp interface. Only one session at the time is supported. While a session is active, connections from other programs running on the same or different computers are rejected until:

Data transfer

Communication occurs through an input and an output stream of bytes. XpressNET™ commands are sent (in both directions) in binary form one after the other without intervening control bytes. Each command transmitted starts with the header and is concluded by the X-OR error detection byte. For further details about commands, refer to the XpressNET™ specifications (PDF file). Since the identification of the end of each command is made possible only by the length field, contained in the lower nibble of the header byte, the correctness of this field is of paramount importance for the proper operation of the interface. Please note that the XnTcp interface supports only XpressNET™ Version 3.0 (current version).

Buffering

TCP implementations do normally delay the transmittal of data until enough bytes to fill the buffer of the receiving machine have been accumulated. In order to avoid this behavior that can result in a slow performance, the sender program must periodically (e.g. after completing the submission of a XpressNET™ command) issue a flush instruction.

Handshaking

Differently from RS-232, TCP provides no RTS/CTS signals nor other ways to determine if the remote site is ready to receive data. In normal circumstances, however, the handshake embedded in the TCP protocol avoids buffer overflow in both directions. Nonetheless, the sender program should avoid submitting too many commands without waiting for replies. Since each command submitted is acknowledged, either by the Command Station, either by the XnTcp interface, a suitable approach is counting outgoing and incoming XpressNET™ commands and make sure that the difference between the two counters does not exceed a given threshold.

Interface commands

The XnTcp interface forwards commands received from the computer to the Command Station and viceversa, without analyzing their contents. An exception is given by commands with hexadecimal F in the upper nibble of the header that, in accordance to XpressNET™ specifications, are processed by the interface itself. The XnTcp supports the following commands:

Hexadecimal
command
Meaning
0xF0 0xF0 Enquiry about interface's hardware and software version
0xF2 0x01 ADR X-Or-byte Enquiry/Change XpressNET™ address of the interface
0xF2 0x02 BAUD X-Or-byte Enquiry/Change baudrate (Changing the baudrate has no practical effect and is supported only for compatibility with RS-232 interfaces)

For a detailed description of the above commands, of interface's replies and of possible error messages sent by the interface, refer to the XpressNET™ specifications.

Keep-alive messages

In order to avoid TCP/IP time-out, when communication has been idle for 4 seconds the XnTcp interface sends to the computer an unsolicited confirmation message (01 04 05).

Delayed Service Mode

When the computer sends a Service Mode command (0x21 010... or 0x22... or 0x23...) and the Command Station is not yet in Service Mode, the XnTcp interface: The above delay is implemented to allow enough time for a relay controlled by A2 to operate. If the Command Station is already in Service Mode, the forwarding of the command is not delayed.

Discovery service

On LANs implementing DHCP, the IP number of the XnTcp interface can be retrieved broadcasting a UDP datagram (default port 61234). The Datagram must be one byte long and must contain the hexadecimal value 25. The XnTcp replies with a datagram 18 bytes long, containing:

Bytes Contents
0-15 NetBios name of the interface (e.g. XNTCP001)
16-17 TCP port number used for XpressNET™ communication (Big endian)

The IP address can be retrieved from the pseudo-header of the Datagram.

XpressNET™ is a trademark of Lenz Electronik, Gmbh