Parameter transmission method, electronic equipment and data interaction system
By implementing the CAN communication interface and protocol conversion functions in embedded devices, the problems of multi-device data transmission and protocol forwarding are solved, the system flexibility and adaptability are improved, and comprehensive data acquisition and exchange are achieved.
Patent Information
- Application Number
- CN202411881387.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-04-25
AI Technical Summary
In the prior art, data transmission between multiple devices depends on the connection of interfaces, resulting in the lack of a connection interface for data transmission in the device, data transmission is limited; in addition, data cannot be forwarded between different protocols, which limits the flexibility and adaptability of the system.
A parameter transmission method is provided, which connects to multiple devices through an embedded device and connects to the central device using a CAN communication interface to realize forwarding and processing of data read and write requests. The method includes receiving a data read request from the central device, dynamically configuring the data read request to a matching CAN protocol, obtaining the collected data of the target device, and storing and transmitting the data to the central device.
It realizes data transmission between multiple devices and data forwarding between different protocols, improves the flexibility and adaptability of the system, breaks the limitations of preset parameters, and realizes comprehensive data acquisition and exchange.
Smart Images

Figure CN119892809A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data reading, and in particular to a parameter transmission method and an electronic device. Background Art
[0002] CAN (Controller Area Network) communication is a multi-master controlled serial communication protocol based on the communication method between multiple devices.
[0003] In the process of implementing the present invention, the inventors found that the prior art has at least the following problems: on the one hand, the transmission of all data between multiple devices depends on the connection of interfaces. When the device lacks a connection interface for data transmission, the data transmission of the device is restricted, affecting the line of sight of communication; on the other hand, in the process of data transmission, usually only fixed preset parameter data can be operated, and data cannot be forwarded between different protocols, which limits the flexibility and adaptability of the system. Summary of the invention
[0004] The embodiments of the present application provide a parameter transmission method, an electronic device, and a data interaction system, which solve the problems of device connection in multi-device data transmission and the inability to forward data between different protocols.
[0005] In the first aspect, an embodiment of the present application provides a parameter transmission method, which is applied to an embedded device based on the CAN protocol, wherein the embedded device is connected to at least one first device through a first interface, and the embedded device is connected to a central device through a CAN communication interface, and the method includes: receiving a data read request from the central device, and forwarding the data read request to a target first device; obtaining collected data of the target first device through the first interface; dynamically configuring the data read request to a matching CAN protocol based on the CAN protocol supported by the central device; storing the collected data in a local register of the embedded device; and transmitting the collected data in the local memory to the central device through the CAN communication interface.
[0006] In one possible implementation, the method also includes: receiving a data write request from the central device, writing the data write request into the local register, wherein the data write request includes the data to be written; forwarding the data write request in the local register to the target first device through the first interface; receiving write success confirmation information from the target first device through the first interface, and storing the write success confirmation information in the local register; and feeding back the write success confirmation information in the local memory to the central device through the CAN communication interface.
[0007] In a possible implementation, after receiving the data write request, the method further includes: dynamically configuring the data write request to a matching CAN protocol based on the CAN protocol supported by the central device.
[0008] In a possible implementation, identity information is configured for the first devices based on the order of first communication between each of the first devices and the embedded device.
[0009] In one possible implementation, configuring identity information for the first devices based on the order of first communication between each of the first devices and the embedded device includes: when the first device among the at least one first device communicates with the embedded device for the first time, configuring the first identity information for the first device; based on the order in which the remaining devices among the at least one first device communicate with the embedded device for the first time, sequentially configuring the second identity information for each remaining device.
[0010] In the second aspect, an embodiment of the present application also provides an electronic device, which is connected to at least one first device through a first interface and to a central device through a CAN communication interface. The electronic device includes: a CAN communication interface, which is used to receive a data read request from the central device; a protocol conversion module, which is used to dynamically configure the data read request to a matching CAN protocol based on the CAN protocol supported by the central device; a data acquisition module, which is used to forward the data read request to a target first device, obtain the collected data of the target first device through the first interface, and store the collected data in a local register of the embedded device; the CAN communication interface is also used to transmit the collected data in the local memory to the central device through the CAN communication interface.
[0011] In one possible implementation, a CAN communication interface is used to receive a data write request from the central device, and write the data write request into the local register, wherein the data write request includes the data to be written; a data acquisition module is used to forward the data write request in the local register to the target first device through the first interface, receive write success confirmation information from the target first device, and store the write success confirmation information into the local register; the CAN communication interface is also used to feed back the write success confirmation information in the local memory to the central device through the CAN communication interface.
[0012] In a possible implementation, the protocol conversion module is further used to dynamically configure the data write request to a matching CAN protocol based on the CAN protocol supported by the central device.
[0013] In a possible implementation, the electronic device further includes: an identity configuration module, configured to configure identity information for the first device based on an initial communication sequence between each of the first devices and the embedded device.
[0014] In one possible implementation, configuring identity information for the first devices based on the order of first communication between each of the first devices and the embedded device includes: when the first device among the at least one first device communicates with the embedded device for the first time, configuring the first identity information for the first device; based on the order in which the remaining devices among the at least one first device communicate with the embedded device for the first time, sequentially configuring the second identity information for each remaining device.
[0015] In the third aspect, an embodiment of the present application also provides a data interaction system, which includes: a central device; one or more first devices; one or more electronic devices provided by the second aspect; wherein the electronic device is connected to the one or more devices through a first interface and connected to the central device through a CAN interface.
[0016] It can be seen from the above technical scheme that the present invention provides a parameter transmission method, which is applied to an embedded device based on the CAN protocol, the embedded device is connected to at least one first device through a first interface, and the embedded device is connected to a central device through a CAN communication interface. The method includes: receiving a data read request from the central device, and forwarding the data read request to the target first device; obtaining the collected data of the target first device through the first interface, dynamically configuring the data read request to a matching CAN protocol based on the CAN protocol supported by the central device, and storing the collected data in the local register of the embedded device, and transmitting the collected data in the local memory to the central device through the CAN communication interface. The present invention supports the simultaneous operation of multiple devices, connects the central device to the CAN bus, realizes data transmission between multiple devices, supports data forwarding between different protocols through internal protocol conversion, flexibly configures and adjusts parameters when the device is running, breaks the preset restrictions, realizes comprehensive data collection and exchange, and realizes the flexibility and adaptability of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0018] Figure 1 A schematic diagram of the structure of an embedded device provided in one embodiment of the present application; Figure 2 A schematic diagram of a data reading and writing process provided for an embodiment of the present application; Figure 3 A data reading flow chart provided for one embodiment of the present application; Figure 4 A schematic diagram of a data writing method flow chart provided in one embodiment of the present application; Figure 5 A data writing flow chart provided for one embodiment of the present application; Figure 6 A schematic diagram of the data interaction system structure provided for one embodiment of the present application. DETAILED DESCRIPTION
[0019] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0020] An embodiment of the present application provides a parameter transmission method, which can be applied to any embedded device that supports the CAN protocol.
[0021] Figure 1 A schematic diagram of the structure of an embedded device provided for one embodiment of the present application.
[0022] In some embodiments, reference Figure 1 As shown, the embedded device may include a main controller module 101 , a CAN communication interface 102 , and a data acquisition module 103 .
[0023] The main controller module 101 may be responsible for coordinating the logical operations of each module, and may include, for example, address management, CAN allocation database, and control of each module.
[0024] The CAN communication interface 102 may include a CAN transceiver and a CAN controller for data exchange.
[0025] The data acquisition module 103 is used to collect data from each first interface of the embedded device and store it in a local register. Exemplarily, each first interface may include a 232 interface, a 485 interface, an AI / AO / DI / DO interface, and other interfaces. In other embodiments, the first interface may also include other types of interfaces, which is not limited in this application.
[0026] In some embodiments, the embedded device provided in the embodiments of the present application is an embedded device that performs data interaction based on the CAN protocol, and the embedded device can be connected to at least one first device through a first interface, and the embedded device is also connected to a central device through a CAN communication interface.
[0027] In some embodiments, reference Figure 1 As shown, the embedded device may further include a protocol conversion module 104 for dynamically configuring a data read request or a data write request to a matching CAN protocol based on the CAN protocol supported by the central device.
[0028] In some embodiments, the embedded device may further include an identity configuration module for configuring identity information for the first devices based on the first communication sequence between each first device and the embedded device.
[0029] In one embodiment, configuring identity information for the first device based on the first communication order between each first device and the embedded device includes: when the first device in at least one first device communicates with the embedded device for the first time, configuring the first identity information for the first device; based on the order in which the remaining devices in at least one first device communicate with the embedded device for the first time, sequentially configuring the second identity information for each remaining device. Exemplarily, in a communication scenario, a central device, an embedded device, and n first devices are included, namely, first device 1, first device 2, ..., first device n. Among the n first devices, when the first device 1 first communicates with the embedded device for the first time, the embedded device can configure the first identity information for the first device 1, wherein the first identity information can be a fixed ID, and the order in which the remaining first devices communicate with the embedded device for the first time is (first device 3, first device 5, first device n, ... first device 8), and then the embedded device can sequentially configure the second identity information for each remaining device based on the order in which the remaining first devices communicate with the embedded device for the first time. Specifically, each time another first device communicates with the embedded device for the first time, the embedded device can sequentially configure IDs for the other first devices that are currently communicating with the embedded device for the first time based on the IDs in the preset ID allocation interval, so that multiple devices can perform read and write operations simultaneously without interfering with each other.
[0030] Figure 2 A flowchart of a data reading method provided in one embodiment of the present application.
[0031] Reference Figure 2 As shown, the method can be applied to an embedded device, and specifically may include the following steps: S201: The embedded device receives a data reading request from a central device, and forwards the data reading request to a target first device.
[0032] S202: The embedded device obtains collected data of the target first device through the first interface; S203: dynamically configuring the data read request to a matching CAN protocol based on the CAN protocol supported by the central device; S204: Storing the collected data in a local register of the embedded device.
[0033] S205: The embedded device transmits the collected data in the local memory to the central device through the CAN communication interface.
[0034] Combine S201 to S205 and Figure 3 As shown in the data reading process, when the central device needs to obtain data provided by the first device from one or more first devices, the central device can obtain the data provided by the first device through the embedded device provided in the embodiment of the present application, and transmit it to the central device after obtaining. Specifically, the embedded device can communicate with the central device through the CAN interface and the CAN bus, supporting dynamic configuration and parameter transmission operations.
[0035] In some embodiments, when the embedded device performs CAN communication with the central device, the data read request can be dynamically configured to a matching CAN protocol based on the CAN protocol supported by the central device. Through the dynamic configuration of the CAN protocol, the communication compatibility and data flexibility between the embedded device and the central device can be improved. Specifically, the central device or the embedded device can perform flexible parameter configuration and adjustment; specifically, a special protocol can be used to allow device parameters to be dynamically configured and adjusted at runtime, rather than being limited to preset parameter data. Exemplarily, a configurable parameter management module can be used to receive and process dynamic configuration commands through a defined communication protocol.
[0036] In some embodiments, data acquisition can be achieved by real-time acquisition of data from any first interface of the embedded device, and the data is stored in a local register. Specifically, a multi-channel data acquisition module is integrated in the embedded device, and the module can connect and collect data from each first interface. After acquiring the data collected by the first interface, the CAN interface can be used to transmit the data and realize data forwarding between different protocols.
[0037] Users can manage the parameter data of the device through parameter tables and host computer tools, and these data may come from local registers or connected sensors. Thanks to the retransmission arbitration mechanism of the CAN bus, it is possible to have higher stability in data transmission. Exemplary, when the central device does not have an RS485 port and an Internet port, it is desired to use a modbus transmission address, the central device can be connected to the embedded device provided by the present application through a CAN interface, and parameter transmission is performed by the parameter transmission method provided by the present application to complete the initialization parameters or parameter upgrades of the device, that is, the register read and write of modbus communication and some extended functions can be realized through CAN communication when the central device does not have an RS485 port and an Internet port.
[0038] Figure 4 A schematic diagram of a data writing method flow chart provided in one embodiment of the present application.
[0039] Reference Figure 4 As shown, the method can be applied to an embedded device, and specifically may include the following steps: S401: The embedded device receives a data write request from a central device, and writes the data write request into a local register, wherein the data write request includes data to be written.
[0040] S402: The embedded device forwards the data write request in the local register to the target first device through the first interface.
[0041] S403: The embedded device receives write success confirmation information from the target first device through the first interface, and stores the write success confirmation information in a local register.
[0042] S404: The embedded device feeds back the write success confirmation information in the local memory to the central device via the CAN communication interface.
[0043] Combine S401 to S404 and Figure 5As shown in the data writing process, when the central device needs to write data to one or more first devices, the central device can write the data to be written into the target first device through the embedded device provided in the embodiment of the present application. Specifically, the embedded device can communicate with the central device through the CAN interface and the CAN bus, and the central device sends a data write request containing the data to be written to the embedded device through the CAN communication, and stores it in the local memory of the embedded device. Then the embedded device can send the data write request in the local memory to the target first device through the first interface between the target first device, so as to support dynamic configuration and parameter transmission operations. Exemplarily, a central device needs to dynamically configure parameters for the target first device, which can be specifically for setting the threshold of the temperature sensor. In this embodiment, the embedded device receives instructions from the central device through the CAN bus, and writes the parameters into its internal register, and then writes the threshold into the temperature sensor through the first interface between the embedded device and the target first device, so as to realize the temperature threshold setting. Among them, the user can specify the target parameter address and value through the CAN command to realize dynamic modification.
[0044] In some embodiments, the data read and write operations are managed through a specific byte structure. Specifically, in the data read process, illustratively, the first byte of the data frame is fixed to 0x22, and this byte is used as an operation code, which is used to indicate that the current operation is a data read operation. The second byte and the third byte of the data frame can both be used to transmit register information, and these bytes specify the address of the register to be read.
[0045] In some embodiments, when data is written, illustratively, the first byte of the data frame is 0x2E, and the first byte is used as an operation code, indicating that this is a data write operation. The second byte and the third byte of the data frame are still used to transmit register information, and determine the register address to which data is to be written. The fourth byte and the fifth byte contain the value to be written, and these bytes carry specific data content.
[0046] Specifically, after the central device sends a message with a data frame of 0x22, the embedded device reads or writes the corresponding register and then transmits the data back to the central device.
[0047] In some embodiments, when the embedded device performs CAN communication with the central device, the data read request is dynamically configured to a matching CAN protocol based on the CAN protocol supported by the central device; or the data write request is dynamically configured to a matching CAN protocol based on the CAN protocol supported by the central device.
[0048] In some embodiments, the central device or the embedded device can perform flexible parameter configuration and adjustment; specifically, a special protocol can be used to allow device parameters to be dynamically configured and adjusted at runtime, rather than being limited to preset parameter data. Exemplarily, a configurable parameter management module can be used to receive and process dynamic configuration commands through a defined communication protocol. It should be noted that in other embodiments, parameter configuration and adjustment can also be performed in other ways, and this application does not limit this.
[0049] Figure 6 A schematic diagram of a data interaction system architecture provided for one embodiment of the present application.
[0050] Reference Figure 6 As shown, the system may include a central device 200; one or more first devices 300; and one or more electronic devices (embedded devices) 100; wherein the embedded device 100 is connected to the one or more first devices 300 via a first interface, and the embedded device 100 is connected to the central device via a CAN interface.
[0051] In other embodiments, the data interaction system may further include multiple central devices, and an embedded device may also be connected to at least two central devices simultaneously through a CAN interface. The present application does not impose any restrictions on the number of central devices.
[0052] In some embodiments, the central device (based on CAN bus) is connected to a data acquisition system through an embedded device, and the data acquisition system may include multiple first devices (may include first device 1, first device 2, ..., first device n). The device collects data such as temperature and pressure in real time during operation, and stores these data in the local register of the embedded device. The data acquisition system periodically reads these data through the CAN bus, and performs data analysis and processing.
[0053] In some embodiments, in order to support the parallel operation of multiple embedded devices on the same bus, devices can be distinguished based on ID allocation rules. Multiple embedded devices may include a reference device and multiple other devices, wherein the reference device is first assigned a fixed ID, and the IDs of the remaining devices are incrementally assigned within a specified interval, and the reference device will try to see if there are other devices responding to its own ID to avoid data conflicts on the same bus, ensuring that each device is unique on the bus. ID conflicts can be effectively avoided, so that multiple devices can perform data transmission operations simultaneously without interfering with each other.
[0054] In some embodiments, the embedded device may also include an ID allocation database to record the current IDs of each device and their status. The device ID usage can be tracked and history and support can be provided when needed. Through this mechanism, the accuracy of data transmission and the efficiency of device operation are guaranteed, thereby optimizing the overall performance of the multi-device system.
[0055] In some embodiments, ID allocation is performed through an internal algorithm of the main controller module to ensure the uniqueness of the device ID on the entire bus, thereby supporting parallel parameter transmission. At this time, a PC or other CAN device can collect data from multiple first devices simultaneously.
[0056] Specifically, multiple devices communicate data via the CAN bus in an actual application scenario. Devices A, B, and C are connected to the CAN bus at the same time. They avoid address bus conflicts through a developed communication protocol and can exchange data stably. For example, device A can transmit its status data to device B, while device C can request specific parameters from device A; external devices can perform one-to-many data transmission operations on all devices at the same time.
[0057] It should be noted that the terminals involved in the embodiments of the present application may include but are not limited to personal computers (PCs), personal digital assistants (PDAs), wireless handheld devices, tablet computers, mobile phones, MP3 players, MP4 players, etc.
[0058] It is understandable that the application may be an application program (nativeApp) installed on the terminal, or may be a web page program (webApp) of a browser on the terminal, which is not limited in the embodiments of the present application.
[0059] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0060] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0061] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0062] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0063] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.
[0064] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
[0065] 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 it. 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 replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A parameter transmission method, characterized in that: Applied to an embedded device based on the CAN protocol, the embedded device is connected to at least one first device via a first interface, and the embedded device is connected to a central device via a CAN communication interface, and the method includes: receiving a data reading request from the central device, and forwarding the data reading request to a target first device; Acquire the collected data of the target first device through the first interface; Dynamically configuring the data read request to a matching CAN protocol based on the CAN protocol supported by the central device; storing the collected data into a local register of the embedded device; The collected data in the local memory is transmitted to the central device through the CAN communication interface.
2. The method according to claim 1, characterized in that The method further comprises: receiving a data write request from the central device, and writing the data write request into the local register, wherein the data write request includes data to be written; forwarding the data write request in the local register to a target first device through the first interface; Receiving, through the first interface, a write success confirmation message from the target first device, and storing the write success confirmation message in the local register; The write success confirmation information in the local memory is fed back to the central device through the CAN communication interface.
3. The method according to claim 2, characterized in that After receiving the data write request, the method further includes: The data write request is dynamically configured to a matching CAN protocol based on the CAN protocol supported by the central device.
4. The method according to claim 1, characterized in that The first devices are configured with identity information based on a first communication sequence between each of the first devices and the embedded device.
5. The method according to claim 4, wherein configuring identity information for each of the first devices based on the first communication order between the first devices and the embedded device comprises: When a first device among the at least one first device communicates with the embedded device for the first time, configuring first identity information for the first device; Based on the order in which the remaining devices in the at least one first device communicate with the embedded device for the first time, the second identity information is sequentially configured for each remaining device.
6. An electronic device, characterized in that: The electronic device is connected to at least one first device via a first interface and connected to a central device via a CAN communication interface, and includes: CAN communication interface, used to receive a data reading request from the central device; A protocol conversion module, used to dynamically configure a data read request to a matching CAN protocol based on the CAN protocol supported by the central device; A data acquisition module, used for forwarding the data reading request to the target first device, acquiring the collected data of the target first device through the first interface, and storing the collected data in the local register of the embedded device; The CAN communication interface is also used to transmit the collected data in the local memory to the central device through the CAN communication interface.
7. The electronic device according to claim 6, characterized in that: A CAN communication interface, used for receiving a data write request from the central device, and writing the data write request into the local register, wherein the data write request includes data to be written; A data acquisition module, used for forwarding the data write request in the local register to the target first device through the first interface, receiving the write success confirmation information from the target first device, and storing the write success confirmation information in the local register; The CAN communication interface is also used to feed back the write success confirmation information in the local memory to the central device through the CAN communication interface.
8. The electronic device according to claim 6, characterized in that: The electronic device further comprises: The identity configuration module is used to configure identity information for each of the first devices based on the first communication sequence between the first devices and the embedded devices.
9. The electronic device according to claim 8, characterized in that: The configuring identity information for the first device based on the first communication order between each of the first devices and the embedded device comprises: When a first device among the at least one first device communicates with the embedded device for the first time, configuring first identity information for the first device; Based on the order in which the remaining devices in the at least one first device communicate with the embedded device for the first time, the second identity information is sequentially configured for each remaining device.
10. A data interaction system, characterized in that: The system comprises: Central equipment; one or more first devices; One or more electronic devices according to any one of claims 6 to 9; The electronic device is connected to the one or more devices via a first interface, and is connected to the central device via a CAN interface.