Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

ServerSuperIO polling communication mode development and what are the matters needing attention

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of ServerSuperIO polling communication mode development and matters needing attention, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this ServerSuperIO polling communication mode development and matters needing attention. Let's take a look at it.

5. Development of polling communication model and matters needing attention

4.1 Overview

Polling communication mode is the earliest and only communication mode of SuperIO, on the basis of which automatic control mode and concurrent mode are added. The ServerSuperIO framework not only has these three communication modes, but also has singleton modes, which will be described in detail later.

When I first took part in the work, I didn't know any communication mode, but at that time, the communication environment in the industrial field was very complex, the communication link of modulation and demodulation, the transmission rate of 300 baud, and strong electromagnetic interference such as geology and cables. data is often interfered. At that time, there was no so-called Internet technology, and in order to ensure the stability of communication, we could only conduct polling communication mode.

4.2 description of communication mechanism

This is the earliest operation mode of the framework, and this control mode can be used in both serial port and network communication. When multiple devices are connected to the communication platform, the communication platform will poll the scheduling equipment for communication tasks. At a certain time, only one device can send a request command and wait for the return data to be received. after the device completes sending and receiving (if it encounters a timeout, it will return automatically), the next device will carry out the communication task and poll the device in turn.

The application scenario is like this, the communication between the server and the device follows the way of answering the call, that is, when the IO is available, the server initiates a communication command request, and the device returns the data to the server after passing the verification according to the command information. This communication mode is easy to understand, and the communication of each device follows the principle of queuing. But what if a device's command needs to be sent in time? ServerSuperIO framework supports device priority scheduling, for example: to detect a device in real time, you need to send commands continuously, then you need to set the device at a high level and send request data commands.

The communication structure is shown below:

4.3 considerations for device driver development 4.3.1 sending data in real time

The ServerSuperIO framework will poll and schedule all devices and send request real-time data commands to the devices in the way of call response. The real-time data commands for the same device are generally relatively fixed. When scheduling a specific device driver, the fixed GetConstantCommand function that calls the IRunDevice driver interface will be called to obtain the command to request real-time data. The code is as follows:

1234567public override byte [] GetConstantCommand () {byte [] data = this .Protocol.DriverPackage ("0", "61", null); string hexs = BinaryUtil.ByteToHex (data); OnDeviceRuningLog ("send > >" + hexs); return data;}

The this.Protocol.DriverPackage driver calls the 61 command to get the command to be sent, and returns the byte [] array. After obtaining the data, ServerSuperIO will automatically send the command data through the IO interface. If the null type is returned, the system does not send.

4.3.2 give priority to sending other data

It is impossible for a device to have only one command to read real-time data, and there may be other commands to interact with each other, such as reading parameters, real-time calibration and so on. There are two ways to have the ServerSuperIO framework schedule the device driver first.

Add the command to the send data cache, and the frame will automatically delete the data from the cache. The code is as follows:

1this .Protocol.SendCache.add ("read parameters", readParaBytes)

two。 Set the priority attribute of the device as follows:

1this .DevicePriority = considerations for DevicePriority.Priority;4.4 host program service instance configuration

When creating a service instance in the host program, you need to set the configuration parameters of the service instance to polling communication mode, and start the service instance to add the instantiated device driver to the service instance. The code is as follows:

12345678910111213141516171819DeviceDriver dev1 = new DeviceDriver (); dev1.DeviceParameter.DeviceName = "Serial device 1"; dev1.DeviceParameter.DeviceAddr = 0; dev1.DeviceParameter.DeviceID = "0"; dev1.DeviceDynamic.DeviceID = "0"; dev1.DeviceParameter.COM.Port = 1; dev1.DeviceParameter.COM.Baud = 9600; dev1.CommunicateType = CommunicateType.COM; dev1.Initialize ("0") IServer server = new ServerFactory () .CreateServer (new ServerConfig () {ServerName = "Service instance 1", SocketMode = SocketMode.Tcp, ControlMode = ControlMode.Loop, CheckSameSocketSession = false, StartCheckPackageLength = false,}); server.Start (); server.AddDevice (dev1)

The ControlMode = ControlMode.Loop code sets the service instance scheduling device to polling control mode.

4.5 polling operation effect

1. Picture

two。 Video

Http://v.qq.com/x/page/o03436yrmu3.html

Attached: description of the class library made by netizens in the group (CHM), netizens' name: norman33,QQ number: 235936468. Thanks to norman33 for building a beautiful community. Download address: http://pan.baidu.com/s/1qXDVIvq

This is the end of the article on "ServerSuperIO polling communication mode development and matters needing attention". Thank you for reading! I believe you all have a certain understanding of the knowledge of "ServerSuperIO polling communication mode development and matters needing attention". If you want to learn more knowledge, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report