Data interaction device, system and method, electronic device and program product
The multi-channel communication service multiplexing of the RS485 serial port is realized through the serial port proxy unit, which solves the problem that the RS485 serial port can only be used by local edge computing services, and realizes flexible, fast and timely interaction between remote control equipment and slave equipment, reducing costs.
Patent Information
- Application Number
- CN202510726830.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-30
- Publication Date
- 2025-08-08
AI Technical Summary
In the prior art, the RS485 serial port can only be used by edge computing communication services built into the collector local area, making it difficult for remote control equipment to obtain data collected by slave equipment in a timely manner, and increases equipment costs or leads to untimely data transmission.
Using a serial proxy unit, two communication services are supported simultaneously through the same RS485 serial port, multiplexing of the RS485 serial port is realized, allowing remote control equipment and local communication services to interact with slave devices at the same time.
It realizes flexible, fast, timely and low-cost interaction with slave equipment, improves the timeliness and accuracy of data transmission, and reduces the demand for hardware resources.
Smart Images

Figure CN120455538A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data interaction device, system, method, electronic device and program product. Background Art
[0002] In related technologies, the collector in the data center can act as a master station and interact with multiple slave devices through an RS485 serial port. For example, it can obtain temperature, humidity, current, voltage and other data collected by the slave devices, or send control instructions to the slave devices.
[0003] However, taking the acquisition of data collected by slave devices as an example, due to the limitations of the RS485 communication protocol (one master and multiple slaves), an RS485 serial port can usually only be used (occupied) by the edge computing communication service built into the collector. As a result, if other devices besides the collector (referred to as remote control devices for ease of description) such as the cloud want to obtain data collected by these slave devices, the following solutions can be used:
[0004] The first method: reconfigure an independent physical serial port for the remote control device.
[0005] This approach has the technical problem of requiring additional hardware resources and increasing equipment costs.
[0006] The second method: Based on the software scheduling mode, the time period for the collector's local edge computing communication service to use the RS485 serial port and the time period for the remote control device's communication service to use the RS485 serial port are specified. The serial port server is used to allow the two services to use (access) the RS485 serial port in turn during different time periods.
[0007] This approach has a technical problem in that the data collected by the slave device cannot be obtained in a timely manner for each service.
[0008] Therefore, there is an urgent need for a technical solution that can interact with slave devices quickly and timely. Summary of the Invention
[0009] Embodiments of the present application provide a data interaction device, system, method, electronic device, and program product for quickly and promptly interacting with a slave device.
[0010] In a first aspect, an embodiment of the present application provides a data interaction device, the device comprising: a first communication service, a second communication service, and a serial proxy unit;
[0011] The first communication service is used to send a first data interaction request to the serial proxy unit;
[0012] The second communication service is used to send a second data interaction request to the serial proxy unit;
[0013] The serial proxy unit is used to forward each received data interaction request of each communication service to the corresponding slave device by calling the RS485 serial port channel; and enable the slave device to respond to each data interaction request.
[0014] In a possible implementation, the first communication service is specifically configured to, if a first data interaction request is received from a remote control device based on a network transparent transmission method, transparently transmit the first data interaction request to the serialproxy unit;
[0015] The serial proxy unit is further configured to, if the first data interaction request is a data acquisition request, identify the slave device required by the remote control device, and forward the first data interaction request to the slave device by calling the RS485 serial port channel; enable the slave device to feed back a first response message corresponding to the first data interaction request to the serial proxy unit based on the RS485 serial port channel, wherein the first response message carries the corresponding data generated by the slave device; and if the first response message is obtained based on the RS485 serial port channel, transparently forward the first response message to the remote control device via Transmission Control Protocol TCP communication.
[0016] In a possible implementation, the second communication service is specifically configured to receive a second data interaction request sent from a local communication service of the data interaction device;
[0017] The serial proxy unit is further used to, if the second data interaction request is a data acquisition request, identify the slave device required by the local communication service, and forward the second data interaction request to the slave device by calling the RS485 serial port channel; enable the slave device to feedback a second response message corresponding to the second data interaction request to the serial proxy unit based on the RS485 serial port channel, where the second response message carries the corresponding data generated by the slave device; if the second response message is obtained based on the RS485 serial port channel, send the second response message to the local communication service through the Modbus protocol.
[0018] In a possible implementation, the serialproxy unit is specifically configured to forward each received data interaction request for each communication service to a corresponding slave device by calling the same RS485 serial port channel in the data interaction device.
[0019] In one possible implementation, the serialproxy unit is specifically configured to create a corresponding virtual serial port for each of the first and second communication services based on the RS485 serial port channel; and for each received data interaction request of the communication service, forward the data interaction request to the corresponding slave device by calling the corresponding virtual serial port according to the communication service of the data interaction request.
[0020] In one possible implementation, the serialproxy unit is further configured to determine whether the corresponding data newly generated by the slave device is pre-cached based on the RS485 serial port channel, and if not, to perform a subsequent step of forwarding the data interaction request to the slave device by calling the RS485 serial port channel;
[0021] If the corresponding data newly generated by the slave device is pre-cached based on the RS485 serial port channel, and the data interaction request is the first data interaction request, the cached corresponding data newly generated by the slave device is transparently forwarded to the remote control device through TCP communication;
[0022] If the corresponding data newly generated by the slave device is pre-cached based on the RS485 serial port channel, and the data interaction request is the second data interaction request, the corresponding data newly generated by the cached slave device is sent to the local communication service via the Modbus protocol.
[0023] In a possible implementation, the serialproxy unit is specifically configured to send the data interaction request to the slave device by calling the RS485 serial port channel according to the identifier of the slave device carried in the data interaction request if the data interaction request is a data write request.
[0024] In a possible implementation, the serialproxy unit is further used to identify the IP address of the remote control device carried in the first data interaction request; if the IP address is included in the pre-saved IP address whitelist, the subsequent step of forwarding the first data interaction request to the corresponding slave device is performed.
[0025] In a second aspect, the present application provides a data interaction system, comprising: the data interaction device, slave device, and remote control device described in any one of the first aspects.
[0026] In a third aspect, the present application further provides a data interaction method, the method comprising:
[0027] receiving a first data interaction request based on a first communication service; and receiving a second data interaction request based on a second communication service;
[0028] For each data interaction request received from the communication service, based on the serialproxy unit, each data interaction request is forwarded to the corresponding slave device by calling the RS485 serial port channel; and the slave device responds to each data interaction request.
[0029] In a fourth aspect, the present application further provides a data interaction device, comprising:
[0030] A receiving module, configured to receive a first data interaction request based on a first communication service; and receive a second data interaction request based on a second communication service;
[0031] The transmission module is used to forward each received data interaction request of each communication service to the corresponding slave device by calling the RS485 serial port channel based on the serial proxy unit; and enable the slave device to respond to each data interaction request.
[0032] In a fifth aspect, the present application further provides an electronic device, which includes at least a processor and a memory, and the processor is used to implement the steps of the method described in any one of the third aspects when executing a computer program stored in the memory.
[0033] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer performs the steps of the method as described in any one of the third aspects.
[0034] In a seventh aspect, an embodiment of the present application provides a computer program product, comprising: a computer program code, which, when executed on a computer, enables the computer to execute the steps of the method described in any one of the third aspects.
[0035] In an embodiment of the present application, based on the serialproxy unit, it can receive both the first data interaction request sent by the first communication service and the second data interaction request sent by the second communication service, that is, it can support two different communication services at the same time, and can realize the multiplexing of the multi-channel communication services of the RS485 serial port (that is, serial port communication multiplexing), so that different communication services can interact with the slave device at the same time based on the same physical serial port, without adding an additional physical serial port, so that it can interact with the slave device flexibly, quickly, timely and at low cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0037] Figure 1 A schematic diagram of a data interaction device provided in an embodiment of the present application;
[0038] Figure 2 A schematic diagram of a data interaction process provided in an embodiment of the present application;
[0039] Figure 3 A schematic diagram of another data interaction process provided in an embodiment of the present application;
[0040] Figure 4 A schematic diagram of another data interaction process provided in an embodiment of the present application;
[0041] Figure 5 A schematic diagram of another data interaction process provided in an embodiment of the present application;
[0042] Figure 6 A schematic diagram of another data interaction process provided in an embodiment of the present application;
[0043] Figure 7 A schematic diagram of a data interaction device provided in an embodiment of the present application;
[0044] Figure 8 A schematic diagram of the data interaction system structure provided in an embodiment of the present application;
[0045] Figure 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0046] In order to make the purpose and implementation of this application clearer, the exemplary implementation of this application will be clearly and completely described below in conjunction with the drawings in the exemplary embodiments of this application. Obviously, the described exemplary embodiments are only part of the embodiments of this application, not all of the embodiments.
[0047] It should be noted that the brief descriptions of terms in this application are only for the purpose of facilitating the understanding of the embodiments described below, and are not intended to limit the embodiments of this application. Unless otherwise specified, these terms should be understood according to their ordinary and usual meanings.
[0048] In the specification and claims of this application and the accompanying drawings, the terms "first," "second," "third," etc. are used to distinguish similar or similar objects or entities, and are not necessarily intended to limit a particular order or sequence, unless otherwise noted. It should be understood that the terms used in this manner are interchangeable under appropriate circumstances.
[0049] The terms "comprise," "include," and "have," and any variations thereof, are intended to cover but not exclude inclusion; for example, a product or device comprising a list of components is not necessarily limited to all the components expressly listed but may include other components not expressly listed or inherent to such product or device.
[0050] The term "module" refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software code that is capable of performing the functionality associated with that element.
[0051] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some or all of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.
[0052] For ease of explanation, the above description has been made with reference to specific embodiments. However, the above exemplary discussion is not intended to be exhaustive or to limit the embodiments to the specific forms disclosed above. Based on the above teachings, various modifications and variations are possible. The above embodiments are selected and described to better explain the principles and practical applications, so that those skilled in the art can better utilize the embodiments and various different variations of the embodiments suitable for specific use considerations.
[0053] Example 1:
[0054] Figure 1A schematic diagram of a data interaction device provided in an embodiment of the present application, the device comprising: a first communication service 101, a second communication service 102, and a serial proxy unit 103;
[0055] The first communication service 101 is configured to send a first data interaction request to the serial proxy unit 103;
[0056] The second communication service 102 is configured to send a second data interaction request to the serial proxy unit 103;
[0057] The serialproxy unit 103 is used to forward each received data interaction request of each communication service to the corresponding slave device by calling the RS485 serial port channel, so that the slave device responds to each data interaction request.
[0058] In one possible implementation, the data interaction device may be a personal computer (PC), a mobile terminal, a server or other electronic device, which is not specifically limited in this application. The data interaction device may be a collector configured (integrated) with a virtual serial proxy unit. That is to say, for example, a serial proxy unit may be configured (integrated) in the integrated collector for dynamic environmental monitoring in the related art, and the optimized collector configured with the serial proxy unit may implement the technical solution provided in the embodiment of this application for two different communication services (such as the original local edge computing communication service of the collector and the communication service of the remote control device), which can interact with the slave device quickly and promptly based on the same physical serial port (RS485 serial port). Among them, a monitoring platform such as the Zhihang platform may be deployed in the remote control device, which is not specifically limited in this application.
[0059] In one possible implementation, when the first communication service in the data interaction device (optimized collector) receives the first data interaction request, it can send the first data interaction request to the serial proxy unit, and when the second communication service in the data interaction device receives the second data interaction request, it can also send the second data interaction request to the serial proxy unit. Among them, the first communication service and the second communication service can respectively refer to the communication service for the remote control device and the edge computing communication service for the original local collector. That is to say, the first communication service and the second communication service can be communication services of two different architectures for the remote control device and the local edge computing, respectively. Of course, the first communication service and the second communication service can also be two different edge computing communication sub-services for the original local collector, or the first communication service and the second communication service can also be communication services for two different remote control devices. This application does not make specific restrictions on this. For ease of understanding, the data interaction process provided by this application is explained below by taking the first communication service as a communication service for remote control devices such as the cloud and the second communication service as an edge computing communication service (local communication service) for the original local collector as an example.
[0060] In one possible implementation, the serial proxy unit may receive a first data interaction request from a first communication service and a second data interaction request from a second communication service. At the same time, the serial proxy unit may receive only the first data interaction request, only the second data interaction request, or both the second data interaction request and the first data interaction request. This application does not impose specific limitations on this. Furthermore, this application does not impose specific limitations on the triggering time and triggering method for the first data interaction request and the second data interaction request, and these can be flexibly configured as needed.
[0061] In one possible implementation, the data interaction request may be a data acquisition request (also referred to as a data read request) for obtaining temperature, humidity, current, voltage and other data collected by a slave device, or it may be a data write request (also referred to as a write data request or a control instruction) for sending some control parameters and other write data to one or more slave devices (such as air conditioners, etc.) to control the slave device. This application does not make any specific restrictions on this.
[0062] For each received data exchange request, the serial proxy unit can forward the data exchange request to the corresponding slave device by invoking the RS485 serial port channel. In one possible embodiment, the data exchange device is configured with an RS485 serial port channel (physical serial port). The serial proxy unit can forward each received data exchange request to the corresponding slave device by invoking the same RS485 serial port channel configured in the data exchange device. After receiving the data exchange request, the slave device can respond to the data exchange request.
[0063] In one possible implementation, when the serial proxy unit forwards each received data interaction request to the corresponding slave device by calling the same RS485 serial port channel configured in the data interaction device, it can create a corresponding virtual serial port for the first communication service and the second communication service based on the same RS485 serial port channel. Thereafter, for each received data interaction request of the communication service (the first data interaction request and the second data interaction request), the data interaction request can be forwarded to the corresponding slave device by calling the corresponding virtual serial port according to the communication service of the data interaction request.
[0064] For example, assuming that the serial proxy unit is based on the same RS485 serial port channel, the virtual serial port created for the first communication service is virtual serial port 1, and the virtual serial port created for the second communication service is virtual serial port 2. When a first data interaction request of the first communication service is received, the first data interaction request can be forwarded to the corresponding slave device by calling the virtual serial port 1 corresponding to the first communication service. When a second data interaction request of the second communication service is received, the second data interaction request can be forwarded to the corresponding slave device by calling the virtual serial port 2 corresponding to the second communication service. Based on this, two different communication services can interact with the slave device quickly and timely based on the same physical serial port (RS485 serial port), realizing the multiplexing of multiple communication services of the RS485 serial port (i.e., serial port communication multiplexing), so that different communication services can simultaneously interact with the slave device based on the same physical serial port, without adding additional physical serial ports, thereby being able to interact with the slave device flexibly, quickly, timely, and at low cost.
[0065] In one possible embodiment, when a first communication service receives a first data exchange request from a remote control device via network transparent transmission, the first communication service may transparently transmit the first data exchange request to a serial proxy unit. When the first data exchange request is a data acquisition request, the serial proxy unit may identify the slave device required by the remote control device, such as a device identifier, register address, and other identification information (referred to as a first identifier for ease of description) of the slave device required by the remote control device. Based on the first identifier, the serial proxy unit may forward the first data exchange request to the slave device required by the remote control device by invoking an RS485 serial port channel. After receiving the first data exchange request (data acquisition request), the slave device required by the remote control device may feedback a first response message corresponding to the first data exchange request to the serial proxy unit via the RS485 serial port channel, the first response message carrying corresponding data generated by the slave device. If the serial proxy unit receives the first response message via the RS485 serial port channel, it may transparently forward the first response message to the remote control device via Transmission Control Protocol (TCP) communication.
[0066] Among them, transparent transmission (network transparent transmission), that is, transparent transmission, means that during the data transmission process, the network is only responsible for transmitting data from the source node (such as the slave device) to the destination node (such as the remote control device), without any processing or parsing of the data content. This transmission method ensures the integrity and consistency of the data, allowing the data to pass through the network "transparently" during the transmission process. It can be seen that through network transparent transmission, the remote control device can obtain the most original data collected by the slave device. However, the local communication service and the slave device need to perform corresponding protocol conversion based on Ethernet network protocols, such as Hypertext Transfer Protocol (HTTP), in order to communicate. The data of the slave device finally obtained by the local communication service is not the most original data collected by the slave device, but the data obtained after protocol parsing and conversion (edge computing). Based on this, in a possible implementation method, when obtaining data from a slave device based on a local communication service and monitoring the data of the slave device, if it is found that the data of the slave device has certain abnormalities, in order to check whether the abnormality is an abnormality in the data collected by the slave device itself or an abnormality caused by edge computing (communication link), a first data interaction request (data acquisition request) can be issued based on a remote control device such as the cloud, and the original data collected by the slave device can be obtained through network transparent transmission. By analyzing the original data collected by the slave device, it is possible to check whether the original data collected by the slave device itself has abnormalities, so that the problems with the slave device (also called monitoring equipment) can be quickly located, thereby improving operation and maintenance efficiency and data quality.
[0067] The process of the serial proxy unit identifying the slave device required by the remote control device can be as follows:
[0068] When the communication service (first communication service) of the remote control device sends a data acquisition request to the serialproxy unit for the first time (first time), the data acquisition request can carry the first identifier of the slave device, such as the device identifier and register address, of the slave device from which the data is to be acquired. The serialproxy unit can identify the first identifier of the slave device and determine the slave device corresponding to the first identifier as the slave device required by the learned remote control device. In order to simplify operations and improve efficiency, when the first communication service subsequently sends a data acquisition request to the serialproxy unit, it can not carry the identifier of the slave device in the subsequent data acquisition request. The serialproxy unit can intelligently determine the slave device corresponding to the previously learned first identifier as the slave device required by the remote control device.
[0069] In one possible implementation, when the remote control device needs to change its required slave device, it can again include the first identifier of the changed slave device in a data acquisition request. The serial proxy unit can then determine the slave device corresponding to the changed first identifier included in the data acquisition request as the most recently learned slave device required by the remote control device. For subsequent data acquisition requests sent by the remote control device, if the data acquisition request no longer includes the identifier of a slave device, the slave device corresponding to the most recently learned changed first identifier can be directly determined as the slave device required by the remote control device. This will not be further described here.
[0070] In one possible implementation, when the serialproxy unit learns the slave device required by the remote control device, in order to improve the efficiency of subsequent data feedback to the remote control device, the serialproxy unit can periodically and continuously obtain the real-time data collected by the slave device with the first identification by calling the RS485 serial port channel according to the set frequency (for ease of description, referred to as the first frequency), and can cache these data. Among them, this application does not make specific restrictions on the first frequency, and it can be flexibly set according to demand. The optimized collector equipped with the serialproxy unit can be used as a master station, and interacts with the slave device with the first identification by calling the RS485 serial port channel, thereby obtaining the data collected by the slave device, which will not be repeated here.
[0071] In one possible implementation, upon receiving a data acquisition request sent by the first communication service of a remote control device, the serialproxy unit may first determine whether the corresponding data newly generated by the slave device required by the remote control device is pre-cached based on the RS485 serial port channel. If so, the cached corresponding data newly generated by the slave device required by the remote control device may be transparently forwarded to the remote control device via TCP communication. If the corresponding data newly generated by the slave device required by the remote control device is not cached, the data acquisition request may be forwarded to the slave device required by the remote control device by calling the RS485 serial port channel. The slave device may, based on the RS485 serial port channel, feed back a first response message corresponding to the data acquisition request to the serialproxy unit, the first response message carrying the corresponding data generated by the slave device. The serial proxy may transparently forward the first response message to the remote control device via TCP communication, which will not be elaborated here.
[0072] In a possible embodiment, before the serial proxy unit obtains the data collected by the slave device with the first identifier by calling the RS485 serial port channel, it can also first determine whether a data acquisition request sent by the remote control device has been received within the set time length. If it has been received, it can be considered that the remote control device still needs the data collected by the slave device with the first identifier, and the serial proxy unit can still obtain the data collected by the slave device with the first identifier based on the RS485 serial port channel according to the first frequency, and cache these data. If the data acquisition request sent by the remote control device is not received within the set time length, it can be considered that the remote control device no longer needs the data collected by the slave device with the first identifier, and the serial proxy unit can no longer obtain the data collected by the slave device with the first identifier by calling the RS485 serial port channel. The specific duration of the set time length can be flexibly set according to demand, and this application does not make specific restrictions on this.
[0073] In one possible embodiment, when the first data interaction request from the remote control device is a data write request (control instruction), the serial proxy unit can identify the write data carried in the data write request and the second identifier of the slave device to be controlled for the write data, and can send the data write request to the corresponding slave device by calling the RS485 serial port channel. After receiving the write data, the slave device can perform corresponding operations based on the write data information carried in the data write request, based on which the control of the slave device can be achieved. The process of the slave device performing corresponding operations based on the write data information will not be repeated here.
[0074] Among them, similar to the process of reading data in the above embodiment, since the local communication service and the slave device need to use an Ethernet-based network protocol, such as HTTP and other protocols to perform corresponding edge computing conversions, the write data in the control instructions received by the slave device from the local communication service is data after edge computing conversion, and is not the most original write data. If a conversion error occurs, it may also cause control failure. Therefore, the timeliness and accuracy of the control instructions sent to the slave device through the local communication service may be poor. The write data in the control instructions sent by the remote control device received by the slave device is received through network transparent transmission. The write data is the original unconverted data. Therefore, the timeliness and accuracy of the control instructions sent by the remote control device to the slave device will be better guaranteed. When it is necessary to control the slave device faster and more accurately, you can choose to send control instructions to the slave device based on the remote control device.
[0075] In one possible implementation, in order to ensure the security of communication, when the data interaction request received by the serial proxy unit is the first data interaction request sent by the remote control device, the serial proxy unit can verify whether the first data interaction request is compliant. Specifically, the IP address of the remote control device carried in the first data interaction request can be identified first, and it can be determined whether the IP address of the remote control device is included in the pre-stored IP address whitelist. If it is included, it can be considered that the first data interaction request is compliant, and the step of forwarding the data corresponding to the first data interaction request to the remote control device or the corresponding slave device through network transparent transmission based on the RS485 serial port channel as described in the above embodiment can be performed. If the IP address of the remote control device is not included in the pre-stored IP address whitelist, it can be considered that the first data interaction request is non-compliant, and the step of forwarding the first data interaction request to the corresponding slave device by calling the RS485 serial port channel as described above can be omitted, and will not be repeated here.
[0076] In a possible embodiment, when the data interaction request received by the serialproxy unit is a second data interaction request for a local communication service from a data interaction device, and the second data interaction request is a data acquisition request, the serialproxy unit can identify the slave device required for the local communication service, such as the device identification, register address and other identification information (for ease of description, referred to as the third identification) of the slave device required for the local communication service, and can forward the second data interaction request to the slave device required for the local communication service by calling the RS485 serial port channel based on the third identification. After the slave device required for the local communication service receives the second data interaction request (data acquisition request), it can feedback a second response message corresponding to the second data interaction request to the serialproxy unit based on the RS485 serial port channel, and the second response message carries the corresponding data generated by the slave device. If the serialproxy unit obtains the second response message based on the RS485 serial port channel, it can send the second response message to the local communication service via the Modbus protocol.
[0077] In one possible implementation, the process of the serial proxy unit identifying the slave device required for the local communication service may be as follows:
[0078] When the local communication service (second communication service) sends a data acquisition request to the serialproxy unit for the first time (first time), the data acquisition request can carry a third identifier such as the device identifier and register address of the slave device from which the data is to be acquired. The serialproxy unit can identify the third identifier of the slave device and determine the slave device with the third identifier as the slave device required by the learned local communication service. In order to simplify operations and improve efficiency, when the local communication service subsequently sends a data acquisition request to the serialproxy unit, it can not carry the identifier of the slave device in the subsequent data acquisition request. The serialproxy unit can intelligently determine the slave device corresponding to the previously learned third identifier as the slave device required by the local communication service.
[0079] In one possible implementation, when a local communication service needs to change its required slave station device, the third identifier of the changed slave station device may be again included in the data acquisition request. The serial proxy unit may determine the slave station device corresponding to the changed third identifier included in the data acquisition request as the most recently learned slave station device required by the local communication service. For subsequent data acquisition requests sent by the local communication service, if the data acquisition request no longer carries the identifier of the slave station device, the slave station device corresponding to the most recently learned changed third identifier may be directly determined as the slave station device required by the local communication service. This will not be further elaborated here.
[0080] In one possible implementation, when the serial proxy unit learns the slave device required by the local edge service unit, in order to improve the efficiency of subsequent data feedback to the local edge service unit, the serial proxy unit can periodically and continuously obtain the real-time data collected by the slave device with a third identifier by calling the RS485 serial port channel at a set frequency (such as the first frequency), and can cache this data. Among them, the optimized collector configured with the serial proxy unit can act as a master station, interacting with the slave device with the third identifier by calling the RS485 serial port channel, thereby obtaining the data collected by the slave device, which will not be repeated here.
[0081] In a possible embodiment, when receiving a data acquisition request sent by a local communication service (second communication service), the serialproxy unit can first determine whether the latest corresponding data generated by the slave device required by the local communication service is pre-cached based on the RS485 serial port channel. If so, the cached latest corresponding data generated by the corresponding slave device can be sent to the local communication service via the Modbus protocol. If the latest corresponding data generated by the slave device required by the local communication service has not been cached, the data acquisition request can be forwarded to the corresponding slave device by calling the RS485 serial port channel. The slave device can feedback a second response message corresponding to the data acquisition request to the serial proxy unit based on the RS485 serial port channel, and the second response message carries the corresponding data generated by the slave device; the serialproxy can send the second response message to the local communication service via the Modbus protocol, which will not be repeated here.
[0082] In one possible implementation, before the serial proxy unit obtains the data collected by the slave device with the third identifier by calling the RS485 serial port channel, it can also first determine whether a data acquisition request sent by the local communication service has been received within a set time period. If it has been received, it can be considered that the local communication service still needs the data collected by the slave device with the third identifier, and the serial proxy unit can still obtain the data collected by the slave device with the third identifier based on the RS485 serial port channel at the first frequency and cache the data. If the data acquisition request sent by the local communication service is not received within the set time period, it can be considered that the local communication service no longer needs the data collected by the slave device with the third identifier, and the serial proxy unit can no longer obtain the data collected by the slave device with the third identifier by calling the RS485 serial port channel.
[0083] Among them, when the slave devices required by the local communication service and the slave devices required by the remote control device include the same slave device, for the same slave device, when the serialproxy unit needs to obtain the data collected by the slave device within a certain collection cycle, it can only obtain the data of the slave device within this collection cycle once (this operation can also be called splicing), without repeating the operation of obtaining the data of the slave device within this collection cycle twice. The data can then be sent to the local communication service and the remote control device respectively, which can avoid repeated operations, improve efficiency and save resources.
[0084] In one possible implementation, when the second data interaction request from the local communication service is a data write request (control instruction), the serialproxy unit can identify the write data carried in the data write request and the fourth identifier of the slave device to be controlled for which the write data is targeted, and can send the data write request to the corresponding slave device by calling the RS485 serial port channel. After the slave device receives the write data, it can perform corresponding operations according to the information of the write data carried in the data write request. Based on this, the control of the slave device can be achieved.
[0085] In a possible implementation, to ensure stability and security of communication, when the first data interaction request and the second data interaction request are received, the legality and compliance of the messages of the first data interaction request and the second data interaction request may be verified.
[0086] Specifically, for remote control devices such as the cloud, the serialproxy unit can store the identifier of the slave device that the remote control device can access or control in advance (for ease of description, referred to as the first reference identifier). When the first data interaction request carries identifiers such as the register address of the slave device, it can be determined whether the identifier of the slave device carried in the first data interaction request is located in the second reference identifier. If it is, it can be considered that the message of the first data interaction request is compliant, and the subsequent step of forwarding the first data interaction request to the corresponding slave device by calling the RS485 serial port channel can be performed. On the contrary, if the identifier of the slave device carried in the first data interaction request is not located in the first reference identifier, it can be considered that the message of the first data interaction request is non-compliant, and a prompt message indicating that the request is non-compliant can be output, and the step of forwarding the first data interaction request to the corresponding slave device by calling the RS485 serial port channel is not performed. This will not be repeated here.
[0087] Similarly, the serial proxy unit can store the identifier of the slave device that the local communication service can access or control in advance (for ease of description, referred to as the second reference identifier). When the second data interaction request carries identifiers such as the register address of the slave device, it can be determined whether the identifier of the slave device carried in the second data interaction request is located in the second reference identifier. If it is, it can be considered that the message of the second data interaction request is compliant, and the step of forwarding the second data interaction request to the corresponding slave device by calling the RS485 serial port channel can be performed. On the contrary, if the identifier of the slave device carried in the second data interaction request is not located in the second reference identifier, it can be considered that the message of the second data interaction request is non-compliant, and a prompt message indicating that the request is non-compliant can be output, and the step of forwarding the second data interaction request to the corresponding slave device by calling the RS485 serial port channel will not be performed. This will not be repeated here.
[0088] In the embodiment of the present application, based on the serial proxy unit, it can receive both the first data interaction request sent by the first communication service and the second data interaction request sent by the second communication service, that is, it can support two different communication services at the same time, and can realize the multiplexing of the multi-channel communication services of the RS485 serial port (that is, serial port communication multiplexing), so that different communication services can simultaneously interact with the slave device for data based on the same physical serial port, without adding an additional physical serial port, so that it can interact with the slave device flexibly, quickly, timely and at low cost.
[0089] In addition, in the embodiment of the present application, based on the RS485 serial port channel, the remote control device can interact with the slave device through network transparent transmission, that is, end-to-end and point-to-point communication between the remote control device and the slave device (underlying device) can be realized, thereby improving the timeliness and accuracy of data interaction.
[0090] For ease of understanding, the data interaction process provided by this application is explained below through a specific embodiment. Figure 2 , Figure 2 A schematic diagram of a data interaction process provided in an embodiment of the present application includes the following steps:
[0091] S201: A first communication service receives a first data interaction request from a remote control device via network transparent transmission, and transparently transmits the first data interaction request to a serial proxy unit. A second communication service receives a second data interaction request from a local communication service of the data interaction device, and sends the second data interaction request to the serial proxy unit.
[0092] S202: For a first data interaction request from a remote control device, the serial proxy unit identifies the IP address of the remote control device carried in the first data interaction request. If the IP address of the remote control device is included in the pre-stored IP address whitelist, proceed to S203.
[0093] S203: Forward the first data interaction request to the corresponding slave device by calling the RS485 serial port channel.
[0094] S204: For the second data interaction request from the local communication service, forward the second data interaction request to the corresponding slave device by calling the RS485 serial port channel.
[0095] For ease of understanding, the data interaction process provided by this application is explained below through a specific embodiment. Figure 3 , Figure 3 A schematic diagram of another data interaction process provided in an embodiment of the present application, the process includes the following steps:
[0096] S301: A first communication service receives a first data interaction request from a remote control device via network transparent transmission, and transparently transmits the first data interaction request to a serial proxy unit. A second communication service receives a second data interaction request from a local communication service of the data interaction device, and sends the second data interaction request to the serial proxy unit.
[0097] S302: If the first data interaction request is a data acquisition request, the serialproxy unit identifies the slave device required by the remote control device, and forwards the first data interaction request to the slave device by calling the RS485 serial port channel. The slave device, based on the RS485 serial port channel, feeds back a first response message corresponding to the first data interaction request to the serial proxy unit. The first response message carries the corresponding data generated by the slave device. In addition, if the second data interaction request is a data acquisition request, the slave device required by the local communication service is identified, and by calling the RS485 serial port channel, the serialproxy unit forwards the second data interaction request to the slave device. The slave device, based on the RS485 serial port channel, feeds back a second response message corresponding to the second data interaction request to the serial proxy unit. The second response message carries the corresponding data generated by the slave device.
[0098] S303: If the serial proxy unit receives a first response message via the RS485 serial port channel, it transparently forwards the first response message to the remote control device via TCP communication. Additionally, if the serial proxy unit receives a second response message via the RS485 serial port channel, it sends the second response message to the local communication service via the Modbus protocol.
[0099] For ease of understanding, the data interaction process provided by this application is explained below through a specific embodiment. Figure 4 , Figure 4 A schematic diagram of another data interaction process provided in an embodiment of the present application, the process includes the following steps:
[0100] S401: A first communication service receives a first data interaction request from a remote control device via network transparent transmission, and transparently transmits the first data interaction request to a serial proxy unit. A second communication service receives a second data interaction request from a local communication service of the data interaction device, and sends the second data interaction request to the serial proxy unit.
[0101] S402: If the first data exchange request is a data write request, the serialproxy unit sends the first data exchange request to the corresponding slave device by invoking the RS485 serial port channel based on the identifier of the slave device carried in the first data exchange request, thereby controlling the slave device. Additionally, if the second data exchange request is a data write request, the serialproxy unit sends the second data exchange request to the corresponding slave device by invoking the RS485 serial port channel based on the identifier of the slave device carried in the second data exchange request, thereby controlling the slave device.
[0102] For ease of understanding, the data interaction process provided by this application is explained below through a specific embodiment. Figure 5 , Figure 5 A schematic diagram of another data interaction process provided in an embodiment of the present application, the process includes the following steps:
[0103] In a possible implementation, one end of the RS485 serial port channel can be connected to the serial port / dev / pts / 0 of the collector, and the other end can be connected to the serial port / dev / pts / 1 of the slave device, that is, the slave device and the collector are connected through the RS485 serial port channel.
[0104] The serial proxy unit is equivalent to an underlying communication service encapsulated within the collector. Remote control devices, such as those in the cloud, can send data exchange requests to the serial proxy unit in the collector over the network. To enable the remote control device to access (request) the serial proxy unit, the collector can inform the remote control device of its own IP address and map the virtual serial port (e.g., port 2000) corresponding to the first communication service created based on the local RS485 serial port channel to the remote control device (exposing the transparent transmission service port) via the Transmission Control Protocol / Internet Protocol (TCP / IP). This allows the remote control device's communication service (the first communication service) to directly access the RS485 device (slave device) connected to the RS485 serial port channel through network transparent transmission based on the collector's local IP address (e.g., 127.0.0.1) and the corresponding virtual serial port (service port). This enables end-to-end, point-to-point communication between the remote control device and the slave device.
[0105] In one possible implementation, when routine monitoring is performed on the data collected from the slave device on a daily basis, a data acquisition request (second data interaction request) can be sent to the serialproxy unit through the local communication service. The local communication service can send a data acquisition request to the serialproxy unit based on the IP address of the collector (127.0.0.1000) and the virtual serial port (such as port 10000) corresponding to the second communication service created based on the local RS485 serial port channel. The serialproxy unit can identify the third identifier of the slave device required by the local communication service, and send the corresponding data obtained from the slave device corresponding to the third identifier based on the RS485 serial port channel to the local communication service (second communication service). In one possible implementation, the original local edge computing unit in the collector can perform corresponding edge computing processing on the data of the slave device with the third identifier obtained. For example, the data can be cleaned, and the data can be parsed and converted into protocols and calculated in real time; if data anomalies are identified (such as data exceeding the corresponding set threshold), corresponding monitoring and alarm operations can be performed; the data can also be standardized so that the data can be adapted to the corresponding monitoring platform (such as remote control devices such as the Zhihang platform). For example, the data of the slave device is converted into a unified format such as JavaScript Object Notation (JSON), Extensible Markup Language (XML) or character-separated values (also known as comma-separated values, CSV). The data can also be converted into a unified unit of measurement, such as converting temperature data into a temperature in degrees Celsius; the data can also be saved in a database (stored in the database). Among them, the process of edge computing of data can adopt existing technology and will not be repeated here. The local edge computing unit can send the standardized data processed by edge computing to the remote control device deployed with the Zhihang platform and other monitoring platforms through the data northbound interface. The remote control device can perform routine monitoring of the data collected by the slave device. This process can be called the "data collection" process or the "data monitoring" process.
[0106] When the remote control device identifies an abnormality in the data of the slave device after edge computing (data from the slave device fed back by the local communication service), in order to check whether the abnormality is an abnormality in the data collected by the slave device itself or an abnormality caused by edge computing (communication link), the remote control device can directly send a data acquisition request (first data interaction request) to the serialproxy unit, obtain the original data collected by the slave device through network transparent transmission, and analyze the original data collected by the slave device to check whether there is an abnormality in the original data collected by the slave device itself. In addition, when it is necessary to control a certain slave device, the remote control device can also send a data write request (control instruction) to the serialproxy unit. The serialproxy unit can identify the write data carried in the data write request and the second identifier of the slave device to be controlled, and can forward the write data to the slave device with the second identifier through network transparent transmission based on the RS485 serial port channel, so that the slave device can be controlled quickly and accurately. This process can be called a "data control" process or a "data control" process.
[0107] This application can achieve monitorable and controllable slave devices by combining local edge computing communication services and remote control device communication services. It can also be called decoupling the acquisition process and the control process to achieve efficient and flexible management of slave devices.
[0108] In one possible implementation, the serial proxy unit can use a KV (key-value) queue caching mechanism to cache (save) data acquired from slave devices. In one possible implementation, for example, an identifier such as a slave device's register address can be used as a key, and the data collected by the slave device can be cached as the value corresponding to the key. Through this caching approach, the serial proxy unit can efficiently and accurately manage acquired slave device data, reducing data loss and improving data synchronization efficiency.
[0109] When the serial proxy unit obtains the data collected by the slave device, it can also record the timestamp corresponding to the data. Through the timestamp, the collection time of the data can be accurately identified. Based on the timestamp, it can be verified whether the real-time data collected by the slave device is obtained in time and the data synchronization can be verified. The timestamp can also be used to avoid data conflicts, for example, to avoid repeatedly sending data with the same collection time to the local communication service or repeatedly sending it to the remote control device.
[0110] The embodiment of the present application is equivalent to innovatively creating multiple virtual serial ports at the operating system level. This design enables the acquisition processes corresponding to communication services of different architectures (local edge communication services and communication services of remote control devices) to access the same physical RS485 port (serial port channel) simultaneously by using different virtual ports. In other words, the present application is equivalent to building a multiplexing protocol layer, which, through virtual serial ports and software scheduling mechanisms, makes communication services of different architectures compatible. Communication services of different architectures can share the same physical RS485 serial port channel without adding additional physical hardware resources, thereby not only improving resource utilization, but also reducing the equipment cost of data center dynamic environment monitoring and improving the flexibility, real-time and accuracy of data interaction.
[0111] In addition, this application also introduces multi-threaded parallel processing technology. The use of this technology enables multiple data exchange requests from local edge computing communication services and remote control device communication services to be processed simultaneously and in parallel based on multiple threads. It can also avoid data interference and data conflicts between different data exchange requests. This efficient parallel processing capability provides a strong guarantee for the real-time and accuracy of data exchange.
[0112] Example 2:
[0113] Based on the same technical concept, this application provides a data interaction method, see Figure 6 , Figure 6 A schematic diagram of another data interaction process provided in an embodiment of the present application, the process includes the following steps:
[0114] S601: Receive a first data interaction request based on a first communication service; and receive a second data interaction request based on a second communication service.
[0115] S602: For each received data interaction request of the communication service, based on the serial proxy unit, each data interaction request is forwarded to the corresponding slave device by calling the RS485 serial port channel; and the slave device responds to each data interaction request.
[0116] The data interaction method provided in the embodiment of the present application is applied to an electronic device, which may be, for example, a PC, a mobile terminal, a server, etc., and the present application does not make any specific limitations on this.
[0117] In a possible implementation, the received data interaction request for each communication service is forwarded to the corresponding slave device by calling the RS485 serial port channel based on the serial proxy unit, including:
[0118] If the first data interaction request is a data acquisition request, the serialproxy unit identifies the slave device required by the remote control device and forwards the first data interaction request to the slave device by calling the RS485 serial port channel; the slave device feeds back a first response message corresponding to the first data interaction request to the serialproxy unit based on the RS485 serial port channel, where the first response message carries the corresponding data generated by the slave device; wherein the first data interaction request is received by the first communication service from the remote control device based on the network transparent transmission mode, and the first data interaction request is transparently transmitted to the serialproxy unit;
[0119] The method further comprises:
[0120] If the serial proxy unit obtains the first response message based on the RS485 serial port channel, the first response message is transparently forwarded to the remote control device through TCP communication.
[0121] In a possible implementation, the received data interaction request for each communication service is forwarded to the corresponding slave device by calling the RS485 serial port channel based on the serial proxy unit, including:
[0122] If the second data interaction request is a data acquisition request, the serial proxy unit identifies the slave device required by the local communication service and forwards the second data interaction request to the slave device by calling the RS485 serial port channel; the slave device feeds back a second response message corresponding to the second data interaction request to the serial proxy unit based on the RS485 serial port channel, where the second response message carries the corresponding data generated by the slave device; wherein the second data interaction request is sent to the serial proxy unit by the second communication service when the second communication service receives the second data interaction request sent by the local communication service of the data interaction device;
[0123] The method further comprises:
[0124] If the second response message is obtained based on the RS485 serial port channel, the second response message is sent to the local communication service through the Modbus protocol.
[0125] In a possible implementation, the serialproxy unit forwards each of the data interaction requests to the corresponding slave device by calling the RS485 serial port channel, including:
[0126] Based on the serial proxy unit, each data interaction request is forwarded to the corresponding slave device by calling the same RS485 serial port channel in the data interaction device.
[0127] In a possible implementation, forwarding each of the data interaction requests to the corresponding slave device by calling the same RS485 serial port channel in the data interaction device includes:
[0128] Based on the RS485 serial port channel, a corresponding virtual serial port is created for the first communication service and the second communication service respectively; for each data interaction request received from the communication service, the data interaction request is forwarded to the corresponding slave device by calling the corresponding virtual serial port according to the communication service of the data interaction request.
[0129] In a possible implementation, after receiving the data interaction request and before forwarding the data interaction request to the corresponding slave device by calling the RS485 serial port channel, the method further includes:
[0130] Determine whether the corresponding data newly generated by the slave device is pre-buffered based on the RS485 serial port channel;
[0131] If not, proceed to the subsequent step of forwarding the data interaction request to the slave device by calling the RS485 serial port channel;
[0132] If the corresponding data newly generated by the slave device is pre-cached based on the RS485 serial port channel, and the data interaction request is the first data interaction request, the cached corresponding data newly generated by the slave device is transparently forwarded to the remote control device through TCP communication;
[0133] If the corresponding data newly generated by the slave device is pre-cached based on the RS485 serial port channel, and the data interaction request is the second data interaction request, the corresponding data newly generated by the cached slave device is sent to the local communication service via the Modbus protocol.
[0134] In a possible implementation, forwarding the data interaction request to the corresponding slave device by calling the RS485 serial port channel includes:
[0135] If the data interaction request is a data write request, the data interaction request is sent to the slave device by calling the RS485 serial port channel according to the identifier of the slave device carried in the data interaction request.
[0136] In a possible implementation, after receiving the first data interaction request and before forwarding the first data interaction request to the slave device, the method further includes:
[0137] Identify the IP address of the remote control device carried in the first data interaction request; if the IP address is included in the pre-stored IP address whitelist, perform a subsequent step of forwarding the first data interaction request to the corresponding slave device.
[0138] Based on the same technical concept, on the basis of the above embodiments, this application provides a data interaction device, see Figure 7 , Figure 7 A schematic diagram of the structure of a data interaction device provided in an embodiment of the present application, the device comprising:
[0139] The receiving module 701 is configured to receive a first data interaction request based on a first communication service, and receive a second data interaction request based on a second communication service;
[0140] The transmission module 702 is used to forward each received data interaction request of each communication service to the corresponding slave device by calling the RS485 serial port channel based on the serialproxy unit; and enable the slave device to respond to each data interaction request.
[0141] In a possible implementation, the transmission module 702 is specifically configured to:
[0142] If the first data interaction request is a data acquisition request, the serialproxy unit identifies the slave device required by the remote control device and forwards the first data interaction request to the slave device by calling the RS485 serial port channel; the slave device feeds back a first response message corresponding to the first data interaction request to the serialproxy unit based on the RS485 serial port channel, where the first response message carries the corresponding data generated by the slave device; wherein the first data interaction request is received by the first communication service from the remote control device based on the network transparent transmission mode, and the first data interaction request is transparently transmitted to the serialproxy unit;
[0143] The transmission module 702 is further configured to:
[0144] If the serial proxy unit obtains the first response message based on the RS485 serial port channel, the first response message is transparently forwarded to the remote control device through TCP communication.
[0145] In a possible implementation, the transmission module 702 is specifically configured to:
[0146] If the second data interaction request is a data acquisition request, the serial proxy unit identifies the slave device required by the local communication service and forwards the second data interaction request to the slave device by calling the RS485 serial port channel; the slave device feeds back a second response message corresponding to the second data interaction request to the serial proxy unit based on the RS485 serial port channel, where the second response message carries the corresponding data generated by the slave device; wherein the second data interaction request is sent to the serial proxy unit by the second communication service when the second communication service receives the second data interaction request sent by the local communication service of the data interaction device;
[0147] The transmission module 702 is further configured to:
[0148] If the second response message is obtained based on the RS485 serial port channel, the second response message is sent to the local communication service through the Modbus protocol.
[0149] In a possible implementation, the transmission module 702 is specifically configured to:
[0150] Based on the serial proxy unit, each data interaction request is forwarded to the corresponding slave device by calling the same RS485 serial port channel in the data interaction device.
[0151] In a possible implementation, the transmission module 702 is specifically configured to:
[0152] Based on the RS485 serial port channel, a corresponding virtual serial port is created for the first communication service and the second communication service respectively; for each data interaction request received from the communication service, the data interaction request is forwarded to the corresponding slave device by calling the corresponding virtual serial port according to the communication service of the data interaction request.
[0153] In a possible implementation, the transmission module 702 is further configured to:
[0154] Determine whether the corresponding data newly generated by the slave device is pre-buffered based on the RS485 serial port channel;
[0155] If not, proceed to the subsequent step of forwarding the data interaction request to the slave device by calling the RS485 serial port channel;
[0156] If the corresponding data newly generated by the slave device is pre-cached based on the RS485 serial port channel, and the data interaction request is the first data interaction request, the cached corresponding data newly generated by the slave device is transparently forwarded to the remote control device through TCP communication;
[0157] If the corresponding data newly generated by the slave device is pre-cached based on the RS485 serial port channel, and the data interaction request is the second data interaction request, the corresponding data newly generated by the cached slave device is sent to the local communication service via the Modbus protocol.
[0158] In a possible implementation, the transmission module 702 is specifically configured to:
[0159] If the data interaction request is a data write request, the data interaction request is sent to the slave device by calling the RS485 serial port channel according to the identifier of the slave device carried in the data interaction request.
[0160] In a possible implementation, the transmission module 702 is further configured to:
[0161] Identify the IP address of the remote control device carried in the first data interaction request; if the IP address is included in the pre-stored IP address whitelist, perform a subsequent step of forwarding the first data interaction request to the corresponding slave device.
[0162] Based on the same technical concept, this application provides a data interaction system, see Figure 8 , Figure 8 This is a schematic diagram of a data interaction system provided in an embodiment of the present application. The system includes the data interaction device 801, the slave device 802 and the remote control device 803 introduced in the above embodiment, which will not be repeated here.
[0163] Based on the same technical concept, the present application also provides an electronic device, Figure 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 9 As shown, it includes: a processor 901, a communication interface 902, a memory 903 and a communication bus 904, wherein the processor 901, the communication interface 902, and the memory 903 communicate with each other through the communication bus 904;
[0164] The memory 903 stores a computer program. When the program is executed by the processor 901, the processor 901 performs the following steps:
[0165] receiving a first data interaction request based on a first communication service; and receiving a second data interaction request based on a second communication service;
[0166] For each data interaction request received from the communication service, based on the serialproxy unit, each data interaction request is forwarded to the corresponding slave device by calling the RS485 serial port channel; and the slave device responds to each data interaction request.
[0167] In a possible implementation, the processor 901 is specifically configured to:
[0168] If the first data interaction request is a data acquisition request, the serialproxy unit identifies the slave device required by the remote control device and forwards the first data interaction request to the slave device by calling the RS485 serial port channel; the slave device feeds back a first response message corresponding to the first data interaction request to the serialproxy unit based on the RS485 serial port channel, where the first response message carries the corresponding data generated by the slave device; wherein the first data interaction request is received by the first communication service from the remote control device based on the network transparent transmission mode, and the first data interaction request is transparently transmitted to the serialproxy unit;
[0169] The processor 901 is further configured to:
[0170] If the serial proxy unit obtains the first response message based on the RS485 serial port channel, the first response message is transparently forwarded to the remote control device through TCP communication.
[0171] In a possible implementation, the processor 901 is specifically configured to:
[0172] If the second data interaction request is a data acquisition request, the serial proxy unit identifies the slave device required by the local communication service and forwards the second data interaction request to the slave device by calling the RS485 serial port channel; the slave device feeds back a second response message corresponding to the second data interaction request to the serial proxy unit based on the RS485 serial port channel, where the second response message carries the corresponding data generated by the slave device; wherein the second data interaction request is sent to the serial proxy unit by the second communication service when the second communication service receives the second data interaction request sent by the local communication service of the data interaction device;
[0173] The processor 901 is further configured to:
[0174] If the second response message is obtained based on the RS485 serial port channel, the second response message is sent to the local communication service through the Modbus protocol.
[0175] In a possible implementation, the processor 901 is specifically configured to:
[0176] Based on the serial proxy unit, each data interaction request is forwarded to the corresponding slave device by calling the same RS485 serial port channel in the data interaction device.
[0177] In a possible implementation, the processor 901 is specifically configured to:
[0178] Based on the RS485 serial port channel, a corresponding virtual serial port is created for the first communication service and the second communication service respectively; for each data interaction request received from the communication service, the data interaction request is forwarded to the corresponding slave device by calling the corresponding virtual serial port according to the communication service of the data interaction request.
[0179] In a possible implementation, the processor 901 is further configured to:
[0180] Determine whether the corresponding data newly generated by the slave device is pre-buffered based on the RS485 serial port channel;
[0181] If not, proceed to the subsequent step of forwarding the data interaction request to the slave device by calling the RS485 serial port channel;
[0182] If the corresponding data newly generated by the slave device is pre-cached based on the RS485 serial port channel, and the data interaction request is the first data interaction request, the cached corresponding data newly generated by the slave device is transparently forwarded to the remote control device through TCP communication;
[0183] If the corresponding data newly generated by the slave device is pre-cached based on the RS485 serial port channel, and the data interaction request is the second data interaction request, the corresponding data newly generated by the cached slave device is sent to the local communication service via the Modbus protocol.
[0184] In a possible implementation, the processor 901 is specifically configured to:
[0185] If the data interaction request is a data write request, the data interaction request is sent to the slave device by calling the RS485 serial port channel according to the identifier of the slave device carried in the data interaction request.
[0186] In a possible implementation, the processor 901 is further configured to:
[0187] Identify the IP address of the remote control device carried in the first data interaction request; if the IP address is included in the pre-stored IP address whitelist, perform a subsequent step of forwarding the first data interaction request to the corresponding slave device.
[0188] The communication bus mentioned in the electronic device mentioned above may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.
[0189] The communication interface 902 is used for communication between the electronic device and other devices.
[0190] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk memory. Alternatively, the memory may be at least one storage device located away from the processor.
[0191] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (NP), etc.; it can also be a digital signal processing processor (DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.
[0192] Based on the same technical concept, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program executable by an electronic device. When the program is run on the electronic device, the electronic device implements the following steps:
[0193] receiving a first data interaction request based on a first communication service; and receiving a second data interaction request based on a second communication service;
[0194] For each data interaction request received from the communication service, based on the serialproxy unit, each data interaction request is forwarded to the corresponding slave device by calling the RS485 serial port channel; and the slave device responds to each data interaction request.
[0195] In a possible implementation, the received data interaction request for each communication service is forwarded to the corresponding slave device by calling the RS485 serial port channel based on the serial proxy unit, including:
[0196] If the first data interaction request is a data acquisition request, the serialproxy unit identifies the slave device required by the remote control device and forwards the first data interaction request to the slave device by calling the RS485 serial port channel; the slave device feeds back a first response message corresponding to the first data interaction request to the serialproxy unit based on the RS485 serial port channel, where the first response message carries the corresponding data generated by the slave device; wherein the first data interaction request is received by the first communication service from the remote control device based on the network transparent transmission mode, and the first data interaction request is transparently transmitted to the serialproxy unit;
[0197] The method further comprises:
[0198] If the serial proxy unit obtains the first response message based on the RS485 serial port channel, the first response message is transparently forwarded to the remote control device through TCP communication.
[0199] In a possible implementation, the received data interaction request for each communication service is forwarded to the corresponding slave device by calling the RS485 serial port channel based on the serial proxy unit, including:
[0200] If the second data interaction request is a data acquisition request, the serial proxy unit identifies the slave device required by the local communication service and forwards the second data interaction request to the slave device by calling the RS485 serial port channel; the slave device feeds back a second response message corresponding to the second data interaction request to the serial proxy unit based on the RS485 serial port channel, where the second response message carries the corresponding data generated by the slave device; wherein the second data interaction request is sent to the serial proxy unit by the second communication service when the second communication service receives the second data interaction request sent by the local communication service of the data interaction device;
[0201] The method further comprises:
[0202] If the second response message is obtained based on the RS485 serial port channel, the second response message is sent to the local communication service through the Modbus protocol.
[0203] In a possible implementation, the serialproxy unit forwards each of the data interaction requests to the corresponding slave device by calling the RS485 serial port channel, including:
[0204] Based on the serial proxy unit, each data interaction request is forwarded to the corresponding slave device by calling the same RS485 serial port channel in the data interaction device.
[0205] In a possible implementation, forwarding each of the data interaction requests to the corresponding slave device by calling the same RS485 serial port channel in the data interaction device includes:
[0206] Based on the RS485 serial port channel, a corresponding virtual serial port is created for the first communication service and the second communication service respectively; for each data interaction request received from the communication service, the data interaction request is forwarded to the corresponding slave device by calling the corresponding virtual serial port according to the communication service of the data interaction request.
[0207] In a possible implementation, after receiving the data interaction request and before forwarding the data interaction request to the corresponding slave device by calling the RS485 serial port channel, the method further includes:
[0208] Determine whether the corresponding data newly generated by the slave device is pre-buffered based on the RS485 serial port channel;
[0209] If not, proceed to the subsequent step of forwarding the data interaction request to the slave device by calling the RS485 serial port channel;
[0210] If the corresponding data newly generated by the slave device is pre-cached based on the RS485 serial port channel, and the data interaction request is the first data interaction request, the cached corresponding data newly generated by the slave device is transparently forwarded to the remote control device through TCP communication;
[0211] If the corresponding data newly generated by the slave device is pre-cached based on the RS485 serial port channel, and the data interaction request is the second data interaction request, the corresponding data newly generated by the cached slave device is sent to the local communication service via the Modbus protocol.
[0212] In a possible implementation, forwarding the data interaction request to the corresponding slave device by calling the RS485 serial port channel includes:
[0213] If the data interaction request is a data write request, the data interaction request is sent to the slave device by calling the RS485 serial port channel according to the identifier of the slave device carried in the data interaction request.
[0214] In a possible implementation, after receiving the first data interaction request and before forwarding the first data interaction request to the slave device, the method further includes:
[0215] Identify the IP address of the remote control device carried in the first data interaction request; if the IP address is included in the pre-stored IP address whitelist, perform a subsequent step of forwarding the first data interaction request to the corresponding slave device.
[0216] The above-mentioned computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor in the electronic device, including but not limited to magnetic storage such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc., optical storage such as CDs, DVDs, BDs, HVDs, etc., and semiconductor storage such as ROMs, EPROMs, EEPROMs, non-volatile memories (NANDFLASH), solid-state drives (SSDs), etc.
[0217] Based on the same technical concept, embodiments of the present application further provide a computer program product, comprising computer program code. When the computer program code is executed on a computer, the computer executes any of the aforementioned embodiments. Because the principles underlying the aforementioned computer program product and the data interaction method are similar, the implementation of the aforementioned computer program product can be referred to as the implementation of the method, and any repetitions will not be repeated.
[0218] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0219] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0220] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0221] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.
[0222] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.
Claims
1. A data interaction device, characterized in that: The data interaction device includes: a first communication service, a second communication service and a serial proxy unit; The first communication service is used to send a first data interaction request to the serial proxy unit; The second communication service is used to send a second data interaction request to the serial proxy unit; The serial proxy unit is used to forward each received data interaction request of each communication service to the corresponding slave device by calling the RS485 serial port channel; and enable the slave device to respond to each data interaction request.
2. The data interaction device according to claim 1, characterized in that: The first communication service is specifically configured to transparently transmit a first data interaction request from a remote control device to the serial proxy unit if the first data interaction request is received from the remote control device based on a network transparent transmission method; The serial proxy unit is further configured to, if the first data interaction request is a data acquisition request, identify a slave device required by the remote control device, and forward the first data interaction request to the slave device by calling an RS485 serial port channel; The slave device feeds back a first response message corresponding to the first data interaction request to the serial proxy unit based on the RS485 serial port channel, where the first response message carries corresponding data generated by the slave device; If the first response message is obtained based on the RS485 serial port channel, the first response message is transparently forwarded to the remote control device through the transmission control protocol TCP communication.
3. The data interaction device according to claim 1, characterized in that: The second communication service is specifically configured to receive a second data interaction request sent from a local communication service of the data interaction device; The serial proxy unit is further configured to, if the second data interaction request is a data acquisition request, identify a slave device required for the local communication service, and forward the second data interaction request to the slave device by calling an RS485 serial port channel; The slave device feeds back a second response message corresponding to the second data interaction request to the serial proxy unit based on the RS485 serial port channel, where the second response message carries the corresponding data generated by the slave device; If the second response message is obtained based on the RS485 serial port channel, the second response message is sent to the local communication service through the Modbus protocol.
4. The data interaction device according to any one of claims 1 to 3, characterized in that: The serial proxy unit is specifically configured to forward each received data interaction request for each communication service to a corresponding slave device by calling the same RS485 serial port channel in the data interaction device.
5. The data interaction device according to claim 4, characterized in that: The serial proxy unit is specifically configured to create a corresponding virtual serial port for each of the first and second communication services based on the RS485 serial port channel; and forward the data interaction request received from each communication service to the corresponding slave device by calling the corresponding virtual serial port according to the communication service of the data interaction request.
6. The data interaction device according to claim 2 or 3, characterized in that: The serial proxy unit is further configured to determine whether the corresponding data newly generated by the slave device is pre-cached based on the RS485 serial port channel, and if not, to perform a subsequent step of forwarding the data interaction request to the slave device by calling the RS485 serial port channel; If the corresponding data newly generated by the slave device is pre-cached based on the RS485 serial port channel, and the data interaction request is the first data interaction request, the cached corresponding data newly generated by the slave device is transparently forwarded to the remote control device through TCP communication; If the corresponding data newly generated by the slave device is pre-cached based on the RS485 serial port channel, and the data interaction request is the second data interaction request, the corresponding data newly generated by the cached slave device is sent to the local communication service via the Modbus protocol.
7. The data interaction device according to any one of claims 1 to 3 and 5, characterized in that: The serialproxy unit is specifically configured to send the data interaction request to the slave device by calling the RS485 serial port channel according to the identifier of the slave device carried in the data interaction request if the data interaction request is a data write request.
8. The data interaction device according to claim 2, characterized in that: The serial proxy unit is further configured to identify the IP address of the remote control device carried in the first data interaction request; if the IP address is included in the pre-stored IP address whitelist, the first data interaction request is subsequently forwarded to the corresponding slave device.
9. A data interaction system, characterized in that: The system comprises: the data interaction device according to any one of claims 1 to 8, a slave device and a remote control device.
10. A data interaction method, characterized in that: The method comprises: receiving, based on the first communication service, a first data interaction request; receiving a second data interaction request based on the second communication service; For each data interaction request received from the communication service, the serial proxy unit forwards each data interaction request to the corresponding slave device by calling the RS485 serial port channel, so that the slave device responds to each data interaction request.
11. An electronic device, characterized in that: include: a memory for storing program instructions; The processor is configured to call the program instructions stored in the memory and execute the steps of the method according to claim 10 according to the obtained program instructions.
12. A computer program product, characterized in that The computer program product comprises: a computer program code, and when the computer program code is run on a computer, the computer is caused to perform the method as claimed in claim 10 .
Citation Information
Patent Citations
Master station and slave station communication device and method
CN110661689A
Implementation method of multiplexing virtual serial port
CN111158865A
Serial port unvarnished transmission device based on SoC system and use method thereof
CN116126757A
Integrated service wireless router of thing networking and system
CN206993143U
Communication Converter with built-in address setting
KR102233681B1