This article describes a multi-function serial device server based on Java. This server can implement the following functions: (1) Accept the signal sent from the specified serial port and forward it to another serial port, broadcast to the local area network, or transfer to other devices within the local area network through the TCP / IP link, thereby implementing the local area network inside Information sharing; (2) Control information sent to the serial port device via TCP / IP link or serial port accepts control information to the serial device.
The first part of this article briefly introduces the serial port equipment server, and the system design of this multi-function serial device server is described in detail. The programming and functional testing of this multi-function serial device server will be described in the second part.
Introduction With the rapid development of network technology, the local area network based on IP technology has become the simplest and effective data exchange and sharing means. However, for many legacy equipment (such as single-chip microcomputer and data acquisition equipment), the only available communication channel is serial port (usually RS-232). These devices are generally equipped with special data acquisition and control software, which are installed on terminals called the master system or on the PC, communicating with the device via the serial port. The data sent from the serial port device is stored on the file system of the master system, and other devices access the master system over the network to achieve the sharing of data. The configuration and control of the serial port device can only be performed by the master system.
The features of these legacy equipment are their "Equipment-Control Terminal - Network" system. When data exchange is involved, the master system is essentially equivalent to a buffer. This buffer process uses a low efficiency disk operation, so that the main control system becomes a bottleneck in the entire data exchange process. The only function of the main control system is to configure and control the serial port device, and the user can only configure and control the serial device through the master system. This not only brings great inconvenience to the user on the use, but also brings hardware resources. Waste.
The function of the serial port device server is to accept the information sent by the serial port device. Real-time uses a serial port, network broadcast, or a TCP / IP link forward to a device that requires this information. At the same time, the serial port equipment server also accepts information from other serial ports or network sent and forwards it to the serial device. Compared with the traditional "equipment-control terminal-network" system, the serial port equipment server has the following advantages:
The serial device server does not retain the exchanged data to the local file system, eliminates the bottleneck (disk operation) in the "Device-Control Terminal-Network" system, thereby improving data exchange and sharing efficiency, guarantee The real-time data of the data. Network Broadcasting Technology enables multiple devices to simultaneously utilize data provided by serial port devices, thereby improving equipment utilization. A serial port device server can serve multiple devices at the same time. The remote device can obtain the data provided by the serial port device via the network so that remote data acquisition and processing may be possible. The remote device can send data to the serial port device over the network, so it is possible to control and configure the device from the remote. Users can control and configure the serial port device server from the remote.
Due to the above technical advantages, the serial device server can be widely used in any system involving data acquisition and processing. In the laboratory, serial equipment servers are used, enabling researchers to monitor the operation of the experimental instrument at home, collect and process experimental data or even adjust the experimental conditions. The serial equipment server is used in the hospital, so that the medical personnel can get data such as ECG and pulse of various patients in the office, which not only improves the medical staff to find out the ability to burst in time, but also reduce the labor intensity of medical staff. A serial device server is used on the spacecraft, and the ground control person can directly obtain the sensor data, correct the error of the system, and even upload the new task module.
This article uses Java to implement a simple multi-function serial port device server. This server is capable of implementing the following features:
Accept the signal sent from the specified serial port and forward it to another serial port, broadcast to the local area network, or transfer to other devices within the LAN through the TCP / IP link. By the TCP / IP link or the serial port accepts the control information sent by other devices and forward it to the serial device. The user's control instruction is accepted by the TCP / IP link to change its own run parameters. The system design is based on the system requirements, which includes the following functional modules: master module, remote control module, and data exchange module.
The function of the master module is to initialize the running parameters and start the remote control module.
The remote control module accepts user instructions through the TCP / IP link and implements the following functions according to the instruction: changing the serial parameters, communicating with the specified serial port device, starts or terminates the specified data exchange module.
The data switching module accepts the output data of the serial port device and forwards to other devices, simultaneous from other devices and forwards to the serial device. Three data exchange modules were designed according to system requirements:
The data broadcast module accepts the output data of the serial port device and broadcasts it to the local area network; TCP / IP data service module, accepts the output data of the serial port device and forward it to the designated client through the TCP / IP link, and accept the client to send Control instructions and forward them to serial port devices; serial port data service modules, accept the output data of the serial port device and forward to other devices through another serial port while receiving the control instruction sent by other devices and forwarding it to the serial device. Name each function module as follows:
Master module - DeviceServer
Remote Control Module - RemoteControl
Data Broadcasting Module - Broadcast
TCP / IP Data Service Module - Servetcp
Serial Data Service Module - Servecom
The above functional modules is implemented as a Java class in the programming design. The correspondence between the functional module and the Java source code file is as follows:
Master module - DeviceServer.java
Remote Control Module - RemoteControl.java
Data Broadcast Module - Broadcast.java
TCP / IP Data Service Module - Servetcp.java
Serial Data Service Module - ServeCom.java
Conclusion This paper introduces the technical advantages and applications of serial port equipment servers in data acquisition and processing, and describes the system design of this multi-function serial device server. The programming and functional testing of this multi-function serial device server will be described in the second part.