[Tutorial on industrial serial port and network software communication platform (SuperIO)] 8. Description of connection between SuperIO communication mechanism and device driver, superio. superio
SuperIO-related information download: http://pan.baidu.com/s/1pJ7lZWf1.1 communication mechanism description
The overall communication mechanism adopts the call response method, that is, the upper computer software sends the request data command. After receiving the command, the lower computer terminal verifies the command and returns the corresponding data.
(1) Serial communication mechanisms include: polling mode.
Serial Bus involves one-to-one communication and one-to-many communication. To avoid data conflicts and environmental interference on the bus, only the polling communication mechanism is used. A device sends and receives data before it can communicate with the next device. However, this communication efficiency is relatively low. To improve the communication efficiency, you can increase the serial port server and implement a serial port on the SuperIO platform to communicate with multiple field devices, that is, load balancing all the devices on the site to different serial ports.
(2) Network communication mechanisms include: polling mode, concurrency mode, and automatic control mode.
The Round Robin mode is the same as the round robin mode in the serial communication mechanism. However, for network communication, this operation mode is very inefficient and cannot reflect the advantages of network communication. Based on this consideration, the concurrency mode and self-control mode are added on the basis of the polling mode.
The concurrency mode is implemented by the SuperIO internally. The sent command package is obtained by calling the GetSendBytes function of the IRunDevice device interface, and the data of all devices is sent in a centralized manner. The received data part adopts the asynchronous listening method to receive data from the corresponding device. The communication cycle of the concurrency mode is uniformly scheduled by the SuperIO platform, and the request data cycle cannot be controlled independently. On this basis, the automatic control mode is added.
Automatic control mode. When developing Device Drivers, secondary developers can regularly send request data commands through OnSendDataHandler. The data receiving part adopts asynchronous listening mode to receive data from the corresponding device, so as to instantly respond to requests.
In another case, the on-site hardware supervisor will send status word data to the host computer software. At this time, it is necessary to actively listen to receive data events, which is not possible in the polling mode. In this case, we recommend that you use the automatic control mode for communication.
1.2 connection between communication mechanisms and Device Drivers
SuperIO consists of two parts: the communication part and the device driver part.
(1) How does the communication part coordinate with the device driver? The two parts mainly implement coordination between the two parts through the IRunDevice interface, and the threads, Asynchronization, and synchronization mechanisms are completed by SuperIO internally.
(2) How do I transmit the received data to the corresponding device? The polling mode does not have this problem. It mainly involves the concurrency mode and automatic control mode, because the two parts adopt the asynchronous data listening mode. There are two ways to solve this problem: first, get the device ID through the receiving protocol driver to identify the corresponding device. Second, identify the corresponding device through the IP address set by the device. The current SuperIO platform uses the second method.
(3) how can the communication interruption be realized in the concurrency and automatic control modes? When the link is disconnected, the Request command does not return the corresponding data, but triggers the interface for running the device. Therefore, the communication status does not change and no response is made. To solve this problem, if the data request command is sent more than three times and no corresponding data is returned each time, the device interface is triggered to complete the entire process of running the device.
Author: QQ: 504547114
QQ group: 54256083
Http://www.bmpj.net
Source Article address: http://www.bmpj.net/index.php? M = article & f = view & id = 8