Methods and apparatus for data communication between devices
By parsing the device list file and establishing a communication link, the mid-level computer communicates with the lower-level peripherals, solving the stability and maintainability problems caused by hard coding, achieving zero-code development and high decoupling, and improving the efficiency of the mid-level computer in adapting to the lower-level peripherals.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HANGZHOU CHANGCHUAN TECH CO LTD
- Filing Date
- 2026-03-10
- Publication Date
- 2026-06-02
AI Technical Summary
The data communication logic between the mid-level machine and the lower-level machine peripherals needs to be hard-coded, resulting in poor stability and maintainability. Furthermore, modifying the communication logic of the lower-level machine peripherals requires a significant amount of manpower.
By parsing the device list file to obtain device link attributes, starting a service thread to establish a communication link, traversing the device data point file to perform data communication between devices, and processing protocol data based on device point information, zero-code development and flexible configuration are achieved.
It reduces the coupling of the communication system, improves the stability and flexibility of communication between devices, reduces the workload of modifying communication logic, and improves the efficiency of the mid-level machine in adapting to the lower-level machine peripherals.
Smart Images

Figure CN122137875A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data communication technology, and in particular to a method and apparatus for data communication between devices. Background Technology
[0002] The mid-level computer is a type of edge computing control gateway used to collect data from various lower-level peripheral devices, and then upload the collected data to the upper-level computer after partial processing. Therefore, the mid-level computer needs to communicate with multiple lower-level peripheral devices.
[0003] In related technologies, the communication processing logic for data communication between the mid-level machine and each lower-level peripheral needs to be implemented through hard coding. Moreover, when editing a lower-level peripheral, the code needs to be modified, resulting in poor stability and maintainability, and requiring a large amount of manpower. Summary of the Invention
[0004] To address the aforementioned technical problems, this disclosure provides a method and apparatus for data communication between devices.
[0005] According to one aspect of the present disclosure, a method for inter-device data communication is provided, comprising: Parse the device list file to obtain the device link attributes of the sub-device to be communicated; Based on the device link attributes of the sub-device to be communicated, a service thread for communicating with the sub-device to be communicated is started; Using the service thread, a communication link is established between the communication sub-device and the communication sub-device based on the device link attribute of the communication sub-device; Using the service thread, the device data point file is traversed to obtain device point information, which includes point data addresses; Based on the device location information, data communication between devices is carried out through the communication link to obtain protocol data.
[0006] In some optional implementations, the step of obtaining protocol data through inter-device data communication via the communication link based on the device location information includes: Based on the device protocol attributes, the device location information is encoded to obtain location encoding information; Based on the location coding information, a communication request instruction is generated; Send the communication request instruction to the sub-device to be communicated; Receive protocol data returned by the communication sub-device according to the communication request instruction.
[0007] In some optional implementations, after obtaining protocol data through inter-device data communication via the communication link, the process includes: According to the device protocol attributes, the protocol data is decoded to obtain the original point data; Based on the first data attribute in the device location information, the original location data is processed to obtain processed data. The first data attribute includes a unified encoding format and the length of bytes occupied. Store the processed data.
[0008] In some optional implementations, after performing the first processing on the original location data based on the first data attribute in the device location information, the method further includes: Based on the second data attribute in the device location information, the processed data is subjected to a second processing to obtain serialized data. The second data attribute includes a data offset attribute. The serialized data is uploaded to the host computer.
[0009] In some optional implementations, the step of performing a second processing on the processed data based on the second data attribute in the device location information to obtain serialized data includes: Acquire at least one set of processed data corresponding to at least one sub-device of the same device type to be communicated; The at least one set of processed data is serialized to obtain serialized data.
[0010] In some alternative implementations, in response to the access of a new communication sub-device, the method further includes: Obtain the device link attributes, device protocol attributes, and device location information of the new communication sub-device; Add the device link attributes and device protocol attributes of the new communication sub-device to the device list file, and generate the device data point file of the new communication sub-device based on the device point information of the new communication sub-device.
[0011] In some optional implementations, the step of using the service thread to traverse the device data point file to obtain device point information includes: Using the service thread, the device data point file is traversed to obtain at least one device point information with consecutive storage addresses.
[0012] In some optional implementations, the step of obtaining protocol data through inter-device data communication via the communication link based on the device location information includes: Based on the location information of at least one device with consecutive storage addresses, a communication request command is generated to conduct data communication between devices and obtain protocol data.
[0013] According to another aspect of the present disclosure, an inter-device data communication apparatus is provided, comprising: The parsing module is used to parse the device list file to obtain the device link attributes of the sub-device to be communicated. The thread startup module is used to start a service thread for communicating with the sub-device based on the device link attributes of the sub-device to be communicated. The link establishment module is used to establish a communication link with the sub-device to be communicated based on the device link attributes of the sub-device to be communicated using the service thread; The traversal module is used to traverse the device data point file using the service thread to obtain device point information, which includes point data addresses. The communication module is used to conduct data communication between devices through the communication link based on the device location information, and obtain protocol data.
[0014] According to another aspect of the present disclosure, a computer-readable storage medium is provided, which stores computer program instructions that, when executed, implement the above-described inter-device data communication method.
[0015] According to another aspect of the present disclosure, an electronic device is provided, the electronic device comprising: Memory, used to store computer program products; A processor is used to execute a computer program product stored in memory, and when the computer program product is executed, it implements the aforementioned inter-device data communication method.
[0016] According to another aspect of the present disclosure, a computer program product is provided, including computer program instructions, which, when executed by a processor, implement the above-described inter-device data communication method.
[0017] Based on the embodiments of this disclosure, by parsing the device list file, the device link attributes of the sub-device to be communicated are obtained. Based on the device link attributes of the sub-device to be communicated, a service thread for communicating with the sub-device to be communicated is started. Then, using the service thread, a communication link is established with the sub-device to be communicated based on the device link attributes of the sub-device to be communicated, and the device data point file is traversed to obtain device point information, including point data addresses. Based on the device point information, data communication between devices is carried out through the communication link to obtain protocol data. This realizes the built-in communication service between devices in a standardized configuration manner, reduces the coupling of the communication system, and when it is necessary to edit the communication processing logic of the sub-device to be communicated or to add a sub-device to be communicated, the configuration can be directly modified. This achieves zero-code development, flexible configuration, high decoupling, and stability of inter-device communication.
[0018] The technical solutions of this disclosure will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0019] The above and other objects, features, and advantages of this disclosure will become more apparent from the more detailed description of the embodiments thereof in conjunction with the accompanying drawings. The drawings are provided to further illustrate the embodiments of this disclosure and form part of the specification. They are used together with the embodiments of this disclosure to explain the disclosure and do not constitute a limitation thereof. In the drawings, the same reference numerals generally represent the same components or steps.
[0020] This disclosure will become clearer with reference to the accompanying drawings and the following detailed description, wherein: Figure 1 This is a system architecture diagram applicable to the device-to-device data communication method disclosed herein; Figure 2 This is a flowchart illustrating an embodiment of the device-to-device data communication method disclosed herein. Figure 3 This is a flowchart illustrating step 205 of the device-to-device data communication method of this disclosure; Figure 4 This is a schematic flowchart of another embodiment of the device-to-device data communication method disclosed herein; Figure 5 This is a schematic flowchart of another embodiment of the device-to-device data communication method disclosed herein; Figure 6 This is a structural diagram of one embodiment of the device-to-device data communication apparatus of this disclosure; Figure 7 This is a structural diagram of another embodiment of the inter-device data communication apparatus of this disclosure; Figure 8 This is a structural diagram of an electronic device for inter-device data communication according to the present disclosure. Detailed Implementation
[0021] Hereinafter, exemplary embodiments according to the present disclosure will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present disclosure, and not all embodiments of the present disclosure, and it should be understood that the present disclosure is not limited to the exemplary embodiments described herein.
[0022] It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values of the components and steps set forth in these embodiments do not limit the scope of this disclosure.
[0023] Those skilled in the art will understand that the terms "first," "second," etc., in the embodiments of this disclosure are only used to distinguish different steps, devices, or modules, and do not represent any specific technical meaning, nor do they indicate a necessary logical order between them.
[0024] It should also be understood that in the embodiments disclosed herein, "multiple" can refer to two or more, and "at least one" can refer to one, two or more.
[0025] It should also be understood that any component, data or structure mentioned in the embodiments of this disclosure can generally be understood as one or more unless expressly defined or given to the contrary in the context.
[0026] Furthermore, the term "and / or" in this disclosure is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this disclosure generally indicates that the preceding and following related objects have an "or" relationship.
[0027] It should also be understood that the description of the various embodiments in this disclosure emphasizes the differences between the various embodiments, and the similarities or similarities can be referred to each other. For the sake of brevity, they will not be described in detail.
[0028] At the same time, it should be understood that, for ease of description, the dimensions of the various parts shown in the accompanying drawings are not drawn according to actual scale.
[0029] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit this disclosure or its application or use.
[0030] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, such techniques, methods, and equipment should be considered part of the specification.
[0031] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.
[0032] The embodiments disclosed herein can be applied to electronic devices such as terminal devices, computer systems, and servers, and can operate together with a wide range of other general-purpose or special-purpose computing system environments or configurations. Examples of well-known terminal devices, computing systems, environments, and / or configurations suitable for use with electronic devices such as terminal devices, computer systems, and servers include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputer systems, mainframe computer systems, and distributed cloud computing environments including any of the above systems, etc.
[0033] Electronic devices such as terminal devices, computer systems, and servers can be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Typically, program modules can include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers can be implemented in distributed cloud computing environments, where tasks are executed by remote processing devices linked through communication networks. In distributed cloud computing environments, program modules can reside on local or remote computing system storage media, including storage devices.
[0034] This disclosure outlines In the process of realizing this disclosure, the inventors discovered through research that the mid-level machine, as an edge computing control gateway, needs to adapt to the communication protocols of various lower-level peripheral devices, including the communication interfaces involved, such as RS-232, RS-485, USB, Bluetooth, and TCP / IP (Transmission Control Protocol / Internet Protocol), as well as data formats, verification methods, command structures, etc. The speed at which the mid-level machine adapts to the lower-level peripheral devices is crucial. However, in related technologies, the process of mid-level machine adapting to lower-level peripheral devices requires multiple processes such as designing data point structures, developing code, debugging and verification, and delivery. When modifying the communication logic of the lower-level peripheral devices, it is also necessary to modify the corresponding code, debug and verify it, etc., which not only consumes a lot of manpower and time, but also the frequent addition and modification of code leads to poor system stability and maintainability.
[0035] In order to improve the efficiency of the mid-level machine in adapting to various lower-level peripherals, the inventors have proposed the technical solution disclosed herein.
[0036] Exemplary System Figure 1 A system architecture diagram applicable to the device-to-device data communication method disclosed herein is shown below. Figure 1As shown, the system may include a host computer 110, a mid-level computer 120, and lower-level peripherals 130 (referred to as "communication sub-devices" in this document). The mid-level computer 120 establishes communication connections with each lower-level peripheral 130 and the host computer 110. The mid-level computer 120 establishes physical connections between the various lower-level peripherals 130, such as through serial cables or network cables, and performs data acquisition and command issuance via wired connections. It also performs partial data calculation and processing on the acquired data from the lower-level peripherals 130 before reporting it to the host computer 120 (industrial control computers and background control systems are collectively referred to as host computers). The mid-level computer 120 can also receive business logic control commands from the host computer 110 and forward them to the corresponding lower-level peripherals 130.
[0037] In the test system of this embodiment, the intermediate host computer 120 maintains a device list file and a device data point file. The device list file enables unified management of all lower-level peripherals 130, while the device data point file maintains device communication and protocol parsing with each lower-level peripheral 130. Therefore, when adding a lower-level peripheral 130 or changing its communication logic, configuration is only required according to the format of the device list file and the device data point file, eliminating the need for coding and improving the efficiency of the intermediate host computer 120 in adapting to each lower-level peripheral 130.
[0038] Exemplary methods Figure 2 This is a flowchart of an embodiment of the device-to-device data communication method disclosed herein; this device-to-device data communication method can be applied to... Figure 1 On the 120 mid-level machine, such as Figure 2 As shown, the data communication method between devices includes the following steps 201 to 205. Each step is explained below.
[0039] In step 201, the device list file is parsed to obtain the device link attributes of the sub-device to be communicated.
[0040] In this embodiment of the disclosure, the device attributes of the connected sub-devices to be communicated recorded in the device list file may include physical link name, device type, application protocol, device number, device address, location file, communication cycle, and whether it is enabled.
[0041] Among them, the physical link name and device type are device link attributes. The physical link name indicates the type of physical medium used for the actual connection between the host computer and the communication sub-device. The device type indicates the function and logical node of the communication sub-device. The application protocol is a device protocol attribute, used to indicate the communication protocol running at the application layer. The device number is the identification information of the communication sub-device; the device address is the communication address of the communication sub-device, such as MAC (Media Access Control Address), IP address, CANID (Controller Area Network Identifier), slave address, etc.; the point file indicates the device data point file of the communication sub-device; the communication cycle indicates the period for collecting data from the communication sub-device; and whether it is enabled indicates whether the communication sub-device is currently enabled.
[0042] In practice, after the mid-level device is powered on, it can parse the device list and obtain the device link attributes of each sub-device to be communicated.
[0043] In this embodiment of the disclosure, the device list file can be a container for device attributes, essentially a linked list of data structures that records the device attributes of the sub-devices to be communicated on the same physical link. An example is as follows: "list":[ { "name":"Test peripherals", "type":"test1", / / Device type "node":1, / / Node name "xml":"test1.xml", / / xml address "link":"com1", / / Physical link name "prot":"MODBUS", / / Application protocol "addr":1, / / Device address "waitTime":"0", / / wait time "commT":100, / / communication cycle "notUse":"0", / / Whether to enable In step 202, a service thread for communicating with the sub-device is started based on the device link attributes of the sub-device to be communicated.
[0044] The service thread is used to continuously monitor the communication status of the communication sub-devices and handle data transmission and reception. To ensure communication between the intermediate host and each communication sub-device, when it is necessary to communicate with the communication sub-device to obtain data, the system's thread creation function can be called based on a multi-threading mechanism to start the service thread for communication with the communication sub-device.
[0045] In this embodiment of the disclosure, the mid-level machine can communicate with multiple sub-devices to be communicated, and therefore multiple service threads can be started accordingly.
[0046] In step 203, a communication link is established between the service thread and the device to be communicated based on the device link attributes of the device to be communicated.
[0047] In this embodiment of the disclosure, the physical link between the device and the sub-device to be communicated can be initialized through a custom protocol step (handshake method) based on the device link attributes of the device, so as to achieve the conditions for normal communication.
[0048] In practice, the host computer can send a specific initialization command or data packet (such as "HELLO" or a predefined command code) to the communication device. After the communication device receives the request, it replies with an acknowledgment response (such as "ACK" or information containing device ID and firmware version). Then, the host computer and the communication device can negotiate communication parameters (such as baud rate and data format).
[0049] In step 204, the service thread is used to traverse the device data point file to obtain device point information, which includes the point data address.
[0050] In this embodiment of the disclosure, the device data point file can be configuration information of the point data that each communication sub-device can collect. The communication sub-device can include various types of sensors and microcontrollers, such as temperature sensors, pressure transmitters, flow meters, level gauges, humidity sensors, etc.
[0051] The data types and addresses of different communication sub-devices can be configured in the device data point file when the sub-device is connected to the host computer. The device point information can include the name of the communication sub-device's point data, the point data address (the memory mapping address of the communication sub-device's point data is the logical address for the host computer to access peripheral hardware such as GPIO (General Purpose Input / Output), timers, and serial ports), the length in bytes occupied, the automatic unified encoding, the data symbol, the data length, the corresponding function code, the coefficient, and the offset.
[0052] The following parameters are used to define the data types: **Byte Length:** This indicates the actual binary storage space occupied by the point data during storage or transmission, such as 4 bytes. **Automatic Unified Encoding:** This indicates the automatic encoding mechanism for each data point (e.g., sensor, measuring point, device parameters) uniquely identifying the point. **Data Symbol:** This indicates whether the point data is signed or unsigned. **Data Length:** This indicates the maximum number of characters or digits that the point data can logically represent. **Function Code:** This is the instruction code in the communication protocol used to instruct the device to perform a specific operation; it's equivalent to a command word. For example, function code 03H (or 0x03) indicates reading the holding register, used to read internal meter measurement data (e.g., voltage, current, power, forward / reverse active energy) or system parameters. **Coefficients:** These include text fields such as "Area," "Status," and "Category," used for grouping, filtering, or visualization. **Offset:** This indicates a processing method for the point data uploaded by the communication device. After offset processing, when transmitting data to the host computer, instead of transmitting the actual data, a byte or record position relative to a known starting point can be transmitted.
[0053] An example of a device data point file is as follows: <?xml version="1.0"encoding="UTF-8"?> <protocol ver="modbus" bigendian="true">< / protocol> <get> <reg> <chiname>Data 1< / chiName> / / Chinese name <engname> data1< / engname> / / English name <addr> 0x200< / addr> / / Point data address <datatype>signed< / dataType> / / Data symbols <funccode>3< / funcCode> Automatic Unified Encoding <bitpos>0< / bitPos> / / bit position <bitlen>16< / bitLen> / / Length in bytes occupied <factor>1< / factor> / / coefficient <offset>0< / offset > / / Offset < / offset> < / factor> < / bitlen> < / bitpos> < / funccode> < / datatype> < / chiname> < / reg> The device data point file clearly shows how the mid-level machine parses and processes the data collected by the communication sub-devices.
[0054] In step 205, based on the device location information, data communication between devices is carried out through the communication link to obtain protocol data.
[0055] In this embodiment, each device can collect multiple types of location information. Based on different device location information (including the name and address of the location data), protocol encoding can be performed to generate communication request instructions, thereby enabling inter-device communication with the sub-device to obtain protocol data. For details, please refer to... Figure 3 The embodiments shown are not described in detail here.
[0056] Protocol data refers to the data obtained by encoding the collected location data according to the application protocol. When transmitting location data through the communication protocol, the location data needs to be encoded using the protocol. For example, if the location data is temperature data and the returned temperature is 12.5 degrees, then a 1 can be sent first to represent the address, then a 4 to represent the length, then a 12.5 to represent the actual transmitted data, and finally one or two bytes to represent the checksum. This data, consisting of the address, length, actual transmitted data, and checksum, constitutes the protocol data.
[0057] Based on the embodiments of this disclosure, by parsing the device list file, the device link attributes of the sub-device to be communicated are obtained. Based on the device link attributes of the sub-device to be communicated, a service thread for communicating with the sub-device to be communicated is started. Then, using the service thread, a communication link is established with the sub-device to be communicated based on the device link attributes of the sub-device to be communicated, and the device data point file is traversed to obtain device point information, including point data addresses. Based on the device point information, data communication between devices is carried out through the communication link to obtain protocol data. This realizes the built-in communication service between devices in a standardized configuration manner, reduces the coupling of the communication system, and when it is necessary to edit the communication processing logic of the sub-device to be communicated or to add a sub-device to be communicated, the configuration can be directly modified. This achieves zero-code development, flexible configuration, high decoupling, and stability of inter-device communication.
[0058] Corresponding to the embodiments of the aforementioned inter-device data communication method, this disclosure also provides embodiments of the inter-device data communication apparatus.
[0059] Figure 3 This is a flowchart illustrating step 205 of the device-to-device data communication method of this disclosure. Figure 3 As shown above, in the above Figure 2 Based on the illustrated embodiment, the specific implementation process of step 205 may include steps 251-254. The steps are described below.
[0060] In step 251, the device location information is encoded based on the device protocol attributes to obtain the location encoding information.
[0061] Among them, the device protocol attribute is the application protocol in the device list file. Different device location information (including the name and address of the location data) is encoded according to the application protocol to obtain the location encoding information.
[0062] In this embodiment of the disclosure, a service thread can be used to traverse the device data point file to obtain at least one device point information with consecutive storage addresses. Here, at least one device point information with consecutive storage addresses refers to device point information with consecutive point data addresses in the sub-device to be communicated.
[0063] In this embodiment of the disclosure, a service thread can be used to traverse the device data point file and obtain at least one device point information with consecutive storage addresses (point data addresses).
[0064] In step 252, a communication request instruction is generated based on the point encoding information.
[0065] The communication request instruction is an instruction that requests the point data collected by the communication sub-device to be uploaded. The communication request instruction may carry point code information.
[0066] Understandably, after collecting point data, each communication sub-device can store the collected point data locally. To facilitate data upload by the communication sub-device, a communication request command can be generated based on at least one device point information with consecutive storage addresses to initiate inter-device data communication and obtain protocol data. Specifically, protocol encoding can be performed on at least one device point information with consecutive storage addresses (point data addresses) to obtain point encoding information. A communication request command can then be used to request the communication sub-device to upload the point data corresponding to multiple device point information with consecutive storage addresses. This reduces the number of memory read / write operations and data transmission operations of the communication sub-device, improving the data transmission efficiency between the intermediate host and the communication sub-device.
[0067] In step 253, a communication request command is sent to the sub-device to be communicated.
[0068] In step 254, the protocol data returned by the communication sub-device according to the communication request instruction is received.
[0069] In this embodiment of the disclosure, after receiving a communication request instruction, the communication sub-device can obtain the point data from the corresponding storage address based on the name and address of the point data in the communication request instruction, and encode the point data according to the application protocol to obtain protocol data.
[0070] Based on the embodiments of this disclosure, a specific implementation method for communication between the host computer and each communication sub-device is disclosed. By performing protocol encoding on at least one device point information with consecutive storage addresses (point data addresses), and requesting the communication sub-device to upload point data corresponding to multiple device point information with consecutive storage addresses through a communication request instruction, the number of memory read / write operations and data transmission operations of the communication sub-device is reduced, thereby improving data transmission efficiency.
[0071] Figure 4 This is a schematic flowchart illustrating another embodiment of the device-to-device data communication method disclosed herein. Figure 4 As shown, this includes steps 401 to 410. Each step is explained below.
[0072] In step 401, the device list file is parsed to obtain the device link attributes of the sub-device to be communicated.
[0073] In step 402, a service thread for communicating with the sub-device is started based on the device link attributes of the sub-device to be communicated.
[0074] In step 403, a communication link is established between the service thread and the sub-device to be communicated, based on the device link attributes of the sub-device to be communicated.
[0075] In step 404, the service thread is used to traverse the device data point file to obtain device point information, which includes the point data address.
[0076] In step 405, based on the device location information, data communication between devices is carried out through the communication link to obtain protocol data.
[0077] For details on the implementation of steps 401 to 405, please refer to [link / reference]. Figure 2 The embodiments shown are not described in detail here.
[0078] In step 406, the protocol data is decoded according to the device protocol attributes to obtain the original point data.
[0079] In this embodiment of the disclosure, after receiving the protocol data, the protocol data can be decoded according to the application protocol to obtain the original point data.
[0080] In step 407, the original location data is processed based on the first data attribute in the equipment location information to obtain the processed data.
[0081] The first data attribute includes the uniform encoding format and the length of bytes occupied.
[0082] In this embodiment of the disclosure, the first processing of the raw location data is used to indicate the process of processing the raw location data into data that can be understood by humans, which is also a kind of encoding process. For example, if the received raw location data is 0x30, it may be understood as 48 if no processing is performed. However, according to the automatic unified encoding format in the device location information, the location data 0x30 can correspond to a space. Therefore, in order to convert it into data that can be understood by the device or humans, the raw location data can be encoded as a space according to the automatic unified encoding format. In addition, the length of bytes occupied by the raw location data can also be processed according to the occupied byte length and the actual length of the raw location data. For example, if the occupied byte length is 4 bytes, but the actual raw location data may only need 2 bytes, the data length of the raw location data can be modified to 2 bytes.
[0083] In other alternative implementations, the raw point data may be subjected to other possible processing, but the specific method of the first processing is not limited here.
[0084] Furthermore, after performing the first processing on the original point data, the processed data can be stored in step 408, or the processed data can be processed a second time in step 409 to obtain serialized data.
[0085] In step 408, the processed data is stored.
[0086] In step 409, based on the second data attribute in the device location information, the processed data is subjected to a second processing to obtain serialized data. The second data attribute includes a data offset attribute.
[0087] In this embodiment of the disclosure, at least one set of processed data corresponding to at least one communication sub-device of the same device type can be obtained, and the at least one set of processed data can be serialized to obtain serialized data.
[0088] The second data attribute may include a data offset attribute, which indicates a processing method for the location data uploaded by the communication sub-device. After performing offset processing, the actual data may not be transmitted when transmitting data to the host computer.
[0089] For example, temperature data may include sub-zero temperatures (negative values), such as -40 degrees. However, when transmitting data, it may be customary not to transmit negative values. Therefore, it may be necessary to add an offset, such as uniformly adding 80 degrees, so that -40 degrees can become 40 degrees.
[0090] It is understandable that the first processing and the second processing are the processing required for storing point data and the processing required for transmitting point data, respectively. The first processing can be performed on the point data according to the data storage needs of the mid-level machine, and further processing can be performed on the stored processed data according to the data transmission needs, and serialization processing can be performed to obtain serialized data.
[0091] In step 410, the serialized data is uploaded to the host computer.
[0092] Based on the embodiments of this disclosure, a specific implementation method is disclosed for a mid-level computer to process, store, and upload point data collected by a communication sub-device to a host computer. The first processing of the acquired point data can convert the raw point data into data that can be understood by humans in advance, while the second processing can convert the data into data suitable for transmission, thus realizing a complete data communication process between devices.
[0093] Figure 5 This is a schematic flowchart illustrating another embodiment of the device-to-device data communication method disclosed herein. Figure 5 As shown, the operation of connecting a new communication sub-device includes steps 501 to 502. The steps are explained below.
[0094] In step 501, the device link attributes, device protocol attributes, and device location information of the new communication sub-device are obtained.
[0095] In this embodiment of the disclosure, the device link attributes, device protocol attributes, and device location information of the new communication sub-device can be obtained through the device user manual of the new communication sub-device.
[0096] The device link attributes include physical link name, device type, and other device attributes used to establish a physical communication link with the host computer. The device protocol attribute is the application protocol of the new communication sub-device. The device location information includes the name of the location data of the sub-device to be communicated, the location data address (the memory mapping address of the location data of the sub-device to be communicated is the logical address of the host computer accessing peripheral hardware such as GPIO (General Purpose Input / Output), timers, and serial ports), the length of bytes occupied, automatic unified encoding, data symbol, data length, corresponding function code, coefficient, and offset.
[0097] In practice, the device user manual can be confirmed by communicating with the device provider, and the device link attributes, device protocol attributes, and device location information of the new communication sub-device can be automatically obtained from the device user manual through text recognition and key information extraction schemes.
[0098] In step 502, the device link attributes and device protocol attributes of the new communication sub-device are added to the device list file, and the device data point file of the new communication sub-device is generated based on the device point information of the new communication sub-device.
[0099] In this embodiment of the disclosure, after obtaining the device link attributes, device protocol attributes, and device location information from the device user manual, the device link attributes, device protocol attributes, and other device attributes can be added to the device list file, and a device data location file for a new communication sub-device can be generated based on the device location information.
[0100] Based on the embodiments of this disclosure, it is possible to quickly connect new devices by configuring and generating device data point files in the device list file without rewriting code, thus achieving zero-code development, flexible configuration, high decoupling and stability for data communication between devices.
[0101] Exemplary device Figure 6 This is a structural diagram of one embodiment of the device-to-device data communication apparatus of this disclosure, which is applied to an electronic device (such as a mid-level computer). Figure 6 As shown, the inter-device data communication device may include: Parsing module 61 is used to parse the device list file to obtain the device link attributes of the sub-device to be communicated; The thread startup module 62 is used to start a service thread for communicating with the sub-device based on the device link attributes of the sub-device to be communicated; Link establishment module 63 is used to establish a communication link with the sub-device to be communicated based on the device link attributes of the sub-device to be communicated using a service thread; The traversal module 64 is used to traverse the device data point file using a service thread to obtain device point information, which includes the point data address. The communication module 65 is used to conduct data communication between devices through a communication link based on device location information to obtain protocol data.
[0102] Figure 7 This is a structural diagram of another embodiment of the inter-device data communication apparatus of this disclosure. Figure 7 As shown above, in the above Figure 6 Based on the illustrated device, in some alternative embodiments, the communication module 65 may include: The encoding submodule 651 is used to encode the device location information based on the device protocol attributes to obtain the location encoding information; The instruction generation submodule 652 is used to generate communication request instructions based on the point encoding information; The instruction sending submodule 653 is used to send a communication request instruction to the sub-device to be communicated; The receiving submodule 654 is used to receive protocol data returned by the communication sub-device according to the communication request instruction.
[0103] In some alternative implementations, the inter-device data communication apparatus may further include: Decoding module 66 is used to decode protocol data according to device protocol attributes to obtain raw point data; The first processing module 67 is used to perform first processing on the original location data based on the first data attribute in the device location information to obtain processed data. The first data attribute includes a unified encoding format and the length of bytes occupied. Storage module 68 is used to store the processed data.
[0104] In some alternative implementations, the inter-device data communication apparatus may further include: The second processing module 69 is used to perform a second processing on the processed data based on the second data attribute in the device location information to obtain serialized data. The second data attribute includes a data offset attribute. The data upload module 70 is used to upload serialized data to the host computer.
[0105] In some alternative implementations, the second processing module 69 may include: The acquisition submodule 691 is used to acquire at least one set of processed data corresponding to at least one communication sub-device of the same device type; The processing submodule 692 is used to serialize at least one set of processed data to obtain serialized data.
[0106] In some alternative implementations, the inter-device data communication apparatus may further include: Information acquisition module 71 is used to acquire the device link attributes, device protocol attributes and device location information of the new communication sub-device in response to the access of the new communication sub-device; File configuration module 72 is used to add the device link attributes and device protocol attributes of the new communication sub-device to the device list file, and to generate the device data point file of the new communication sub-device based on the device point information of the new communication sub-device.
[0107] In some optional implementations, the traversal module 64 is specifically used to traverse the device data point file using a service thread to obtain at least one device point information with consecutive storage addresses.
[0108] In some alternative implementations, the communication module 65 is specifically used to perform inter-device data communication by generating a communication request instruction based on at least one device location information with consecutive storage addresses, thereby obtaining protocol data.
[0109] The modules and units in this disclosed device can be further divided into finer-grained units according to actual needs, and the specific configuration can be set according to actual needs.
[0110] The apparatus of this disclosure embodiment can be used to implement the methods of the above embodiments of this disclosure. The two correspond to each other in specific implementation, and the specific implementation of related parts can be referred to each other, which will not be repeated here.
[0111] Exemplary electronic devices, computer program products, and computer-readable storage media This disclosure also provides an electronic device, including: a memory for storing a computer program; and a processor for executing the computer program stored in the memory, wherein when the computer program is executed, it implements the inter-device data communication method of any of the above embodiments of this disclosure.
[0112] Below, for reference Figure 8 This describes an electronic device according to embodiments of the present disclosure, wherein apparatus for implementing methods according to embodiments of the present disclosure may be integrated. Figure 8 This is a structural diagram of an electronic device provided in an illustrative embodiment of the present disclosure, such as... Figure 8 As shown, the electronic device includes one or more processors 11, one or more memory 12 of computer-readable storage media, and a computer program stored in the memory and executable on the processor. When the program in the memory 12 is executed, the aforementioned inter-device data communication method can be implemented.
[0113] Specifically, in practical applications, the electronic device may also include components such as an input device 13 and an output device 14, which are interconnected via a bus system and / or other forms of connection mechanisms (not shown). Those skilled in the art will understand that... Figure 8 The structure of the electronic device shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or certain components, or different component arrangements. Wherein: The processor 11 may be a central processing unit (CPU) or other form of processing unit with inter-device data communication capability and / or instruction execution capability. It performs various functions and processes data by running or executing software programs and / or modules stored in memory 12 and calling data stored in memory 12, thereby performing overall monitoring of the electronic device.
[0114] The memory 12 can store one or more computer program products. The memory can include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program products can be stored on the computer-readable storage medium, and the processor 11 can run the computer program products to implement the inter-device data communication methods and / or other desired functions of the various embodiments of this disclosure described above.
[0115] The input device 13 can be used to receive input numerical or character information. The input device 13 may include a keyboard, mouse, joystick, etc., related to user settings and function control.
[0116] The output device 14 can output various information to the outside, including determined distance information, direction information, etc. The output device 14 may include, for example, a display, a speaker, a printer, and a communication network and its connected remote output devices, etc.
[0117] The electronic device may also include a power supply for powering various components, which can be logically connected to the processor 11 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and any other components.
[0118] Of course, for the sake of simplicity, Figure 8 Only some of the components of the electronic device relevant to this disclosure are shown, omitting components such as buses, input / output interfaces, etc. In addition, the electronic device may include any other suitable components depending on the specific application.
[0119] In addition to the methods and apparatus described above, embodiments of this disclosure may also be computer program products, including computer program instructions that, when executed by a processor, cause the processor to perform the steps in the inter-device data communication methods according to various embodiments of this disclosure as described in the "Exemplary Methods" section of this specification.
[0120] Computer program products can be written in any combination of one or more programming languages to perform the operations of the embodiments of this disclosure. The programming languages include object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on a user's computing device, partially on a user's computing device, as a standalone software package, partially on a user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0121] Furthermore, embodiments of this disclosure may also be computer-readable storage media storing computer program instructions thereon, which, when executed by a processor, cause the processor to perform the steps in the inter-device data communication methods according to various embodiments of this disclosure as described in the "Exemplary Methods" section above.
[0122] Computer-readable storage media may take the form of any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may, for example, include, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0123] The basic principles of this disclosure have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this disclosure are merely examples and not limitations. These advantages, benefits, and effects should not be considered as essential features of each embodiment of this disclosure.
[0124] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For system embodiments, since they largely correspond to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0125] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as ROM, RAM, magnetic disk, or optical disk.
[0126] The methods and apparatus of this disclosure may be implemented in many ways. For example, they may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order of steps for the method is for illustrative purposes only, and the steps of the method of this disclosure are not limited to the order specifically described above, unless otherwise specifically stated. Furthermore, in some embodiments, this disclosure may also be implemented as a program recorded on a recording medium, the program including machine-readable instructions for implementing the method according to this disclosure. Thus, this disclosure also covers recording media storing programs for performing the method according to this disclosure.
[0127] The description in this disclosure is provided for illustrative and descriptive purposes only and is not intended to be exhaustive or to limit the disclosure to its forms. Many modifications and variations will be apparent to those skilled in the art. The embodiments were chosen and described in order to better illustrate the principles and practical application of this disclosure and to enable those skilled in the art to understand this disclosure and to design various embodiments with various modifications suitable for a particular purpose.< / get>
Claims
1. A method for data communication between devices, characterized in that, include: Parse the device list file to obtain the device link attributes of the sub-device to be communicated; Based on the device link attributes of the sub-device to be communicated, a service thread for communicating with the sub-device to be communicated is started; Using the service thread, a communication link is established between the communication sub-device and the communication sub-device based on the device link attribute of the communication sub-device; Using the service thread, the device data point file is traversed to obtain device point information, which includes point data addresses; Based on the device location information, data communication between devices is carried out through the communication link to obtain protocol data.
2. The method according to claim 1, characterized in that, The step of obtaining protocol data through inter-device data communication via the communication link based on the device location information includes: Based on the device protocol attributes, the device location information is encoded to obtain location encoding information; Based on the location coding information, a communication request instruction is generated; Send the communication request instruction to the sub-device to be communicated; Receive protocol data returned by the communication sub-device according to the communication request instruction.
3. The method according to any one of claims 1-2, characterized in that, After obtaining protocol data through inter-device data communication via the communication link, the process includes: According to the device protocol attributes, the protocol data is decoded to obtain the original point data; Based on the first data attribute in the device location information, the original location data is processed to obtain processed data. The first data attribute includes a unified encoding format and the length of bytes occupied. Store the processed data.
4. The method according to claim 3, characterized in that, After performing a first processing on the original location data based on the first data attribute in the device location information, the process further includes: Based on the second data attribute in the device location information, the processed data is subjected to a second processing to obtain serialized data. The second data attribute includes a data offset attribute. The serialized data is uploaded to the host computer.
5. The method according to claim 4, characterized in that, The second processing of the processed data based on the second data attribute in the device location information to obtain serialized data includes: Acquire at least one set of processed data corresponding to at least one sub-device of the same device type to be communicated; The at least one set of processed data is serialized to obtain serialized data.
6. The method according to any one of claims 1-5, characterized in that, In response to the access of a new communication sub-device, it also includes: Obtain the device link attributes, device protocol attributes, and device location information of the new communication sub-device; Add the device link attributes and device protocol attributes of the new communication sub-device to the device list file, and generate the device data point file of the new communication sub-device based on the device point information of the new communication sub-device.
7. The method according to any one of claims 1-6, characterized in that, The step of using the service thread to traverse the device data point file to obtain device point information includes: Using the service thread, the device data point file is traversed to obtain at least one device point information with consecutive storage addresses.
8. The method according to claim 7, characterized in that, The step of obtaining protocol data through inter-device data communication via the communication link based on the device location information includes: Based on the location information of at least one device with consecutive storage addresses, a communication request command is generated to conduct data communication between devices and obtain protocol data.
9. A device-to-device data communication apparatus, characterized in that, include: The parsing module is used to parse the device list file to obtain the device link attributes of the sub-device to be communicated. The thread startup module is used to start a service thread for communicating with the sub-device based on the device link attributes of the sub-device to be communicated. The link establishment module is used to establish a communication link with the sub-device to be communicated based on the device link attributes of the sub-device to be communicated using the service thread; The traversal module is used to traverse the device data point file using the service thread to obtain device point information, which includes point data addresses. The communication module is used to conduct data communication between devices through the communication link based on the device location information, and obtain protocol data.
10. A computer-readable storage medium, characterized in that, The storage medium stores computer program instructions, which, when executed, implement the method described in any one of claims 1-8.