Key technologies for serial-to-Ethernet conversion
2026-04-06 08:01:06··#1
1. Overview: Serial-to-Ethernet conversion can now be achieved using serial-to-Ethernet modules, making it very simple and easy to use. However, some new problems and common misconceptions arise in this technology and require attention. Serial-to-Ethernet conversion is not simply a change in transmission medium, but a protocol conversion from serial to TCP/IP. Key technologies involved include: TCP/IP operating modes, serial framing technology, and 9-bit technology. This section analyzes these serial-to-Ethernet technologies in detail. 2. Clarifying a Concept: Is it serial-to-Ethernet or serial-to-TCP/IP? A serial port is generally a UART, which actually only defines the data link layer specifications, namely start bits, data bits, and stop bits. However, at different physical layers, it is further divided into: TTL serial ports, RS232 serial ports, RS485 serial ports, etc. TTL serial port: This is a serial port for data communication between MCU chips. It uses +5V (or +3.3V) to represent 1 and GND to represent 0. RS232 serial port: This is a serial port for communication between devices. Its main function is to change the signal voltage from 0-5V to ±15V (usually ±12V). This increased voltage increases the data transmission distance and reliability. RS485 serial port: This is a serial port for long-distance communication, capable of transmitting data over thousands of meters. Its main feature is the use of a differential-mode signal (the voltage between lines A and B) instead of the RS232 common-mode signal (the voltage between the signal line and GND), thus resisting common-mode interference and enabling longer-distance transmission. If we follow the ISO 7-layer model (physical layer, data link layer, network layer, transport layer, session layer, presentation layer, application layer), the serial port actually only includes the physical and data link layers. The TCP/IP protocol belongs to the network and transport layers. Therefore, "serial port to TCP/IP" is not accurate. Ethernet belongs to the physical and data link layers, so "serial port to Ethernet" is more accurate. Since most protocols running on Ethernet are currently TCP/IP, serial-to-Ethernet conversion can also be described as serial-to-TCP/IP conversion. 3. Key Technology of Serial-to-Ethernet Conversion: TCP/IP Working Mode Issues. Serial-to-Ethernet conversion is not a simple conversion between the physical layer and data link layer. Because the serial protocol itself does not have a network layer or transport layer, serial-to-Ethernet conversion actually uses serial data as TCP/IP application layer data, encapsulated and transmitted using TCP/IP. TCP/IP application layer data is the truly valid data that TCP/IP needs to transmit. For example, what users receive and send using the socket's recv() and send() functions is actually application layer data. Thus, through serial-to-TCP/IP conversion, users can use recv() and send() functions to send and receive serial data. However, TCP/IP is not as simple as recv() and send(). Depending on the working mode, it involves connection, closure, listening, etc., which are the additional processing parts required after serial-to-Ethernet conversion. TCP/IP working modes can be divided into: TCP Server mode, TCP Client mode, and UDP mode. UDP Mode: UDP mode is connectionless; data can be sent as soon as it's available, without prior connection. Therefore, this mode is closer to serial communication. However, UDP cannot guarantee data integrity and is prone to errors. TCP Mode: TCP mode uses a reliable data transmission mechanism, ensuring minimal data loss and error-free transmission. TCP communication necessarily consists of two ends: a TCP client and a TCP server. The concepts of TCP client and TCP server can be compared to a telephone call. The TCP client is the one making the call, and the TCP server is the one answering. How to choose the TCP/IP working mode? TCP vs. UDP: Prioritize TCP mode, especially for large data transmissions over the internet, as UDP is prone to errors and data loss. Choosing between TCP client and TCP server: Follow these principles: Principle 1: The party initiating data transmission should be the client. For example, in a data acquisition system, the acquisition terminal should be the client. This is because when a TCP connection is broken, the client can actively establish a connection when data needs to be sent. A TCP server, on the other hand, can only passively accept connections, preventing data transmission. Principle Two: The party with a fixed IP or domain name is the server. For example, in a scenario with multiple data acquisition terminals and only one central server, the central server should be the server. This is because the central server's IP or domain name is generally fixed, while the IPs of the acquisition terminals are constantly increasing and changing. The central server has difficulty remembering all the IPs of the acquisition terminals, making it difficult to initiate connections; while it is relatively easy for the acquisition terminals to find the central server. 4. Key Technology Two for Serial-to-Ethernet Conversion: Serial Framing Technology Serial data can be sent continuously, while Ethernet data is sent in packets. This raises the question of how long the serial data should be packaged into an Ethernet packet for transmission. Packet Length: Ethernet packets are up to 1500 bytes long, so the serial-to-Ethernet converter must package and send 1500 bytes after receiving them. Users can set this packet length limit. Packet Interval: Besides packet length as a rule for serial framing, a more logical method is through packet intervals. When the serial-to-TCP/IP forwarder detects an idle time of T milliseconds in the serial data stream, it considers the previously received serial data ready to be sent as an Ethernet packet. Here, T is the user-defined packet interval. Key technology three for serial-to-Ethernet conversion: 9-bit technology. Ethernet data is calculated in bytes, with each byte being 8 bits. However, serial data may contain 9 bits. The 9th bit is often used to distinguish between address frames and data frames; 1 indicates an address frame, and 0 indicates a data frame. Therefore, how to transmit the 9th bit after serial-to-Ethernet conversion becomes a key technology. Many serial-to-Ethernet solutions discard the 9th bit. Currently, it is understood that Shanghai Zhuolan Information Technology's solution has the ability to quickly adapt to 9 bits, and its implementation uses a protocol called RealCom. Because of the added 9th bit, serial data cannot be directly and transparently converted into TCP/IP application layer data. The RealCom protocol packages the serial data and transmits the entire data as TCP/IP application data. This allows the RealCom protocol header to include information about whether the 9th bit of the data packet is 1 or 0, thus achieving 9-bit transmission technology.