A data communication method, apparatus, device, and medium

By introducing a virtual common address translation mechanism into I2C bus communication, the problem of needing to modify the hardware circuit layout for individual configuration of complex devices is solved, thereby improving bus utilization and communication security and avoiding resource waste.

CN119988273BActive Publication Date: 2025-11-25SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510198786.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-02-21
Publication Date
2025-11-25
Estimated Expiration
2045-02-21

Smart Images

  • Figure CN119988273B_ABST
    Figure CN119988273B_ABST
Patent Text Reader

Abstract

The application discloses a data communication method, device, equipment and medium, relates to the technical field of communication, and is applied to a master device, and comprises the following steps: a target bus is listened to, so that a current communication request on the target bus is acquired; a slave device address carried by the current communication request is compared with a slave device address in a preset configuration table, so that it is determined whether a plurality of communication requests for the same group of slave devices are included in the current communication request; if the plurality of communication requests for the same group of slave devices are included in the current communication request, the plurality of communication requests are transmitted to corresponding virtual public addresses in the preset configuration table, so that, after a slave device in the same group of slave devices listens to the virtual public address and finds that there is a communication request that needs to be responded by the slave device, the slave device performs a corresponding response operation to obtain a response result; and a plurality of response results corresponding to the plurality of communication requests and returned by the same group of slave devices in batches are acquired. The application improves bus utilization and communication security.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of communication technology, and in particular to a data communication method, apparatus, device, and medium. Background Technology

[0002] The I2C (Inter-Integrated Circuit) bus is a two-wire serial bus used to connect microcontrollers and their peripheral devices. It is a widely adopted bus standard in the field of microelectronic communication and control. It is a special form of synchronous communication, with advantages such as fewer interface lines, simpler control methods, smaller device packages, and higher communication speeds.

[0003] I2C transmits information between devices connected to the bus via serial data (SDA) and serial clock (SCL) lines. Each device has a unique address and can act as either a transmitter or receiver (depending on its function). The master device initializes data transmission on the bus and generates the clock signal that allows transmission. At this point, any addressed device is considered a slave. Typically, an I2C link operates in a master-slave configuration, meaning related communication messages are broadcast throughout the link. This poses a risk of information leakage and tampering. Attackers can use any link device with master functionality to scan local devices and eavesdrop on link communications, or even impersonate a master device to modify the registers of other devices. Honeypot technology is a network security technique designed to lure potential attackers through deception and enticement. It deploys decoy hosts, network services, or information to induce attackers to attack these decoys, allowing the attack to be captured and analyzed. Honeypot systems can collect information about the attacker's tools and methods, attack intentions, and motives, helping defenders understand the security threats they face and take technical and managerial measures to strengthen the security capabilities of their systems. In some technologies, a deserializing device is used for batch read / write operations. Multiple identical I2C devices are connected to the deserializing device, which is essentially a hierarchical management method. The upper level only communicates with the deserializing device, which then distributes the data to the lower level. However, this method is suitable for simple sensor devices. Complex devices, in addition to a unified configuration, require fine-grained individual configurations, making this method less advantageous in terms of individual configuration. This method requires specific modifications to the hardware circuit layout, transforming it into a cascaded structure, resulting in a significant amount of additional work.

[0004] It is evident that how to perform data communication without modifying the hardware circuit layout is a problem that needs to be solved by those skilled in the art. Summary of the Invention

[0005] The purpose of this invention is to provide a data communication method, apparatus, device, and medium that enables data communication without modifying the hardware circuit layout, while improving bus utilization.

[0006] In a first aspect, the present invention discloses a data communication method applied to a main device, comprising:

[0007] Listen to the target bus to obtain the current communication requests on the target bus;

[0008] The slave device address carried in the current communication request is compared with the slave device address in the preset configuration table to determine whether the current communication request includes multiple communication requests for the same group of slave devices; the preset configuration table is used to record the slave device addresses of several groups of slave devices and their corresponding virtual common addresses, with each group of slave devices corresponding to a different virtual common address;

[0009] If the current communication request includes multiple communication requests for the same group of slave devices, then the multiple communication requests will be transmitted to the corresponding virtual public address in the preset configuration table, so that the slave devices in the same group can perform the corresponding response operation after listening to the communication request that requires their response on the virtual public address, and obtain the response result.

[0010] Retrieve multiple response results corresponding to multiple communication requests returned in batches from the same group of slave devices.

[0011] Optionally, before comparing the slave device address carried in the current communication request with the slave device address in the preset configuration table, the following steps are also included:

[0012] The slave devices are grouped according to their type, and the group number corresponding to each group of slave devices is determined; slave devices in the same group have the same type.

[0013] Determine whether the internal register addresses of all slave devices in the same group are the same;

[0014] If the internal register addresses of all slave devices in the same group are the same, then a virtual common address is randomly generated for each slave device in the same group to obtain the virtual common slave device address.

[0015] If the internal register addresses of each slave device in the same group are different, then the virtual common address corresponding to each internal register of each slave device in the same group is generated based on the internal register address of any slave device in the same group, so as to obtain the virtual common register address.

[0016] A preset configuration table is constructed based on the group number of each slave device, the slave device address, the slave device's internal register address, the virtual common slave device address, and the virtual common register address.

[0017] Optionally, if the current communication request includes multiple communication requests for the same group of slave devices, then the multiple communication requests are transmitted to the corresponding virtual public address in the preset configuration table, including:

[0018] If the current communication request includes multiple communication requests for the same group of slave devices, and the internal register addresses of each slave device in the same group are the same, then the multiple communication requests will be transmitted to the corresponding virtual common slave device address in the preset configuration table.

[0019] If the current communication request includes multiple communication requests for the same group of slave devices, and the internal register addresses corresponding to each slave device in the same group are different, then the multiple communication requests will be transmitted to the corresponding virtual common register addresses in the preset configuration table.

[0020] Optionally, the slave device address carried in the current communication request is compared with the slave device address in the preset configuration table to determine whether the current communication request includes multiple communication requests for the same group of slave devices, including:

[0021] Compare the slave device address carried in the current communication request with the slave device address in the preset configuration table;

[0022] If the addresses of each slave device carried in the current communication request are the same as the corresponding slave device addresses in the same group of slave devices in the preset configuration table, then it is determined that the current communication request includes multiple communication requests for the same group of slave devices.

[0023] Otherwise, it is determined that the current communication request does not include multiple communication requests for the same group of slave devices.

[0024] Optionally, after determining whether the current communication request includes multiple communication requests for the same group of slave devices, the following may also be included:

[0025] If the current communication request does not include multiple communication requests for the same group of slave devices, the current communication request is directly sent to the corresponding slave device according to the slave device address carried in the current communication request, so that after the slave device receives the communication request to respond to, it executes the corresponding response operation and returns the corresponding response result to the master device.

[0026] Optionally, after a slave device in the same group detects a communication request on a virtual public address that requires its response, the process of executing the corresponding response operation to obtain the response result also includes:

[0027] Determine whether the slave device has completed receiving the current communication request when the target bus is idle;

[0028] If the slave device completes the reception of the current communication request, it determines whether the received communication request is complete, obtains the corresponding determination result, and then the slave device performs the corresponding response operation based on the determination result to obtain the response result.

[0029] Optionally, the corresponding judgment result is obtained so that the slave device can perform a corresponding response operation based on the judgment result to obtain the response result, including:

[0030] If the received communication request is complete, the corresponding response operation is performed by the slave device in the same group of slave devices to the communication request that needs to be responded to on the virtual public address, so as to obtain the response result;

[0031] If the received communication request is incomplete, the process jumps back to the step of transmitting multiple communication requests to the corresponding virtual public address in the preset configuration table, so that the slave device can listen again for communication requests that require its own response on the virtual public address.

[0032] In a second aspect, the present invention discloses a data communication device applied to a main device, comprising:

[0033] The communication request acquisition module is used to listen to the target bus in order to obtain the current communication requests on the target bus;

[0034] The determination module is used to compare the slave device address carried in the current communication request with the slave device address in the preset configuration table to determine whether the current communication request includes multiple communication requests for the same group of slave devices; the preset configuration table is used to record the slave device addresses of several groups of slave devices and their corresponding virtual common addresses, with each group of slave devices corresponding to a different virtual common address;

[0035] The communication request transmission module is used to transmit multiple communication requests to the corresponding virtual public address in the preset configuration table if the current communication request includes multiple communication requests for the same group of slave devices. This allows the slave devices in the same group to perform corresponding response operations after listening to the communication request that requires their response on the virtual public address, so as to obtain the response result.

[0036] The response result acquisition module is used to acquire multiple response results corresponding to multiple communication requests returned in batches by the same group of slave devices.

[0037] Thirdly, the present invention provides an electronic device, comprising:

[0038] Memory, used to store computer programs;

[0039] A processor is used to execute computer programs to implement the aforementioned data communication methods.

[0040] Fourthly, the present invention provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, it implements the aforementioned data communication method.

[0041] In this invention, the master device listens to the target bus to obtain the current communication requests on the target bus; it compares the slave device address carried in the current communication request with the slave device address in the preset configuration table to determine whether the current communication request includes multiple communication requests for the same group of slave devices; the preset configuration table is used to record the slave device addresses of several groups of slave devices and their corresponding virtual common addresses, with each group of slave devices corresponding to a different virtual common address; if the current communication request includes multiple communication requests for the same group of slave devices, the multiple communication requests are transmitted to the corresponding virtual common address in the preset configuration table, so that the slave devices in the same group, after listening to the existence of communication requests that require their own response on the virtual common address, execute the corresponding response operation to obtain the response result; and the master device obtains multiple response results returned in batches by the same group of slave devices corresponding to multiple communication requests.

[0042] Beneficial effects: This invention, by setting up a virtual common address translation mechanism, allows the master device to detect current communication requests on the bus. It first determines whether the current communication request includes multiple communication requests targeting the same group of slave devices. If so, it uses the virtual common address to send these multiple communication requests in a single batch. This improves bus utilization, and the presence of the virtual common address also enhances communication security. Attached Figure Description

[0043] To more clearly illustrate the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0044] Figure 1 A flowchart of a data communication method provided in an embodiment of the present invention;

[0045] Figure 2 A schematic diagram of a data communication framework provided in an embodiment of the present invention;

[0046] Figure 3 A schematic diagram of a management module structure provided in an embodiment of the present invention;

[0047] Figure 4 A flowchart illustrating a specific data communication method provided in an embodiment of the present invention;

[0048] Figure 5This is a schematic diagram of a data communication device structure provided in an embodiment of the present invention;

[0049] Figure 6 This is a structural diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0050] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of the present invention.

[0051] In some technologies, a deserializing device is used for batch read / write operations. Multiple identical I2C devices are connected to the deserializing device, which is essentially a hierarchical management method. The upper level only communicates with the deserializing device, which then distributes the data to the lower level. However, this method is suitable for simple sensor devices. Complex devices, in addition to a unified configuration, require fine-grained individual configurations, making this method less advantageous in terms of individual configuration. This method requires specific modifications to the hardware circuit layout, transforming it into a cascaded structure, resulting in a significant amount of additional work. To solve the above technical problems, this invention discloses a data communication method, apparatus, device, and medium that enables data communication without modifying the hardware circuit layout, while simultaneously improving bus utilization.

[0052] See Figure 1 As shown, this embodiment of the invention provides a data communication method applied to a main device, including:

[0053] Step S11: Listen to the target bus to obtain the current communication requests on the target bus.

[0054] In this embodiment of the invention, after system link initialization, the master and slave devices power on and perform preparation work based on their respective configurations. Then, the master device listens to the integrated circuit bus. When there is an integrated circuit bus communication request on the bus, the master device obtains the current communication request on the bus and parses the current communication request to obtain the slave device address carried in the current communication request.

[0055] Step S12: Compare the slave device address carried in the current communication request with the slave device address in the preset configuration table to determine whether the current communication request includes multiple communication requests for the same group of slave devices; the preset configuration table is used to record the slave device addresses of several groups of slave devices and their corresponding virtual common addresses, with each group of slave devices corresponding to a different virtual common address.

[0056] In this embodiment of the invention, a management module is introduced on the I2C communication link, containing a set of management tables that integrate register addresses with the same configuration strategy into a group. For example... Figure 2 As shown, assuming an I2C bus has a master device, slave device 1, slave device 2, slave device 3, and slave device 4, this invention connects a management module to the bus. The management module can be integrated into the master device or can be a separate device with storage functionality. The initial configuration table is manually entered and recorded through master-slave communication. The management module completes register grouping and virtual address generation based on the configuration information, and completes a series of configuration processes. For example, Figure 3 As shown, the management module includes an internal register, a processing module, and a transmission module. The processing and transmission modules are connected to the I2C bus. The processing module is responsible for automatically grouping and generating virtual addresses based on configuration information, and storing the configuration information and virtual address-related information in the internal register. After initialization, the processing module listens for communication related to virtual addresses and records the response from slave devices. The internal register stores grouping information and the virtual address generated for that group. The transmission module works with the processing module to confirm data with each group of slave devices; simultaneously, it receives bus data transmission information and transmits it to the processing module for analysis. It should also be noted that this invention can be applied not only to I2C communication links but also to other open communication links.

[0057] Therefore, before comparing the slave device address carried in the current communication request with the slave device address in the preset configuration table, the slave devices are grouped according to their type, and the group number corresponding to each group of slave devices is determined. Slave devices in the same group have the same type. It is then determined whether the internal register addresses corresponding to each slave device in the same group are the same. If the internal register addresses corresponding to each slave device in the same group are the same, a virtual common address corresponding to each slave device in the same group is randomly generated to obtain the virtual common slave device address. If the internal register addresses corresponding to each slave device in the same group are different, a virtual common address corresponding to each internal register of each slave device in the same group is generated based on the internal register address of any slave device in the same group to obtain the virtual common register address. The preset configuration table is constructed based on the group number, slave device address, internal register address of the slave device, virtual common slave device address, and virtual common register address of each slave device. The specific preset configuration table is shown in Table 1.

[0058] Table 1

[0059]

[0060] Among them, the serial number is used to identify each record. For read requests within the same group, each device will respond sequentially according to this encoding order. The group serial number distinguishes different groups. The slave device address stores the address of the slave device within the same group; each slave device address is unique. The internal register address is the address of the device's internal register, storing configuration information or sensor data. The virtual slave device address is a common slave device address generated by the management module. The virtual common register address is used by default for the same internal register address within the same group. If the internal register addresses of two devices are different, the management module will generate a virtual address as the common register address. Data validity: Optionally, after batch transmission, the transmission module will confirm with each device whether the data has been received. Devices that have not been written to will be marked and reported. In one specific embodiment, devices are grouped according to their similarity. Devices 1 and 2 are grouped together, generating a virtual address of 0x88. Devices 3 and 4 are grouped together, generating a virtual address of 0x78. Since the internal register addresses of devices 3 and 4 are different, a second-order virtual address of 0x02 is generated.

[0061] In this embodiment of the invention, the slave device addresses carried in the current communication request are compared with the slave device addresses in a preset configuration table. If each slave device address carried in the current communication request is the same as the corresponding slave device address in the same group of slave devices in the preset configuration table, then it is determined that the current communication request includes multiple communication requests for the same group of slave devices; otherwise, it is determined that the current communication request does not include multiple communication requests for the same group of slave devices. In other words, it determines whether the slave devices targeted by the current communication request are in the same group. If they are, then the device communication data packet is determined to be a batch-accessible request within the group; otherwise, it is determined that the device communication data packet is not a batch-accessible request within the group.

[0062] Step S13: If the current communication request includes multiple communication requests for the same group of slave devices, then the multiple communication requests are transmitted to the corresponding virtual common address in the preset configuration table, so that the slave devices in the same group can perform the corresponding response operation after listening to the communication request that needs to be responded to on the virtual common address, so as to obtain the response result.

[0063] In this embodiment of the invention, after determining whether the current communication request includes multiple communication requests for the same group of slave devices, if the current communication request includes multiple communication requests for the same group of slave devices, then the multiple communication requests are transmitted to the corresponding virtual common address in the preset configuration table. Specifically, if the current communication request includes multiple communication requests for the same group of slave devices, and the internal register addresses corresponding to each slave device in the same group are the same, then the multiple communication requests are transmitted to the corresponding virtual common slave device address in the preset configuration table; if the current communication request includes multiple communication requests for the same group of slave devices, and the internal register addresses corresponding to each slave device in the same group are different, then the multiple communication requests are transmitted to the corresponding virtual common register address in the preset configuration table. Afterwards, when a slave device in the same group detects a communication request on the virtual common address that requires its own response, it can execute the corresponding response operation to obtain a response result.

[0064] In addition, if the current communication request does not include multiple communication requests for the same group of slave devices, the current communication request is directly sent to the corresponding slave device according to the slave device address carried in the current communication request, so that after the slave device receives the communication request to respond to, it can perform the corresponding response operation and return the corresponding response result to the master device.

[0065] In this embodiment of the invention, when a slave device in the same group detects a communication request on a virtual public address that requires its response, it performs a corresponding response operation to obtain a response result. During this process, when the target bus is idle, it determines whether the slave device has completed receiving the current communication request. If the slave device has completed receiving the current communication request, it determines whether the received communication request is complete, obtains the corresponding determination result, and then performs the corresponding response operation based on the determination result to obtain a response result. More specifically, if the received communication request is complete, the slave device in the same group performs the corresponding response operation on the communication request on the virtual public address that requires its response to obtain a response result. If the received communication request is incomplete, it jumps back to the step of transmitting multiple communication requests to the corresponding virtual public address in the preset configuration table, so that the slave device can re-monitor for communication requests on the virtual public address that require its response. In other words, when a slave device detects its own virtual address request, it will complete the ACK (Acknowledge character) response and complete data reception. The management module will confirm that the slave device has completed data reception when the bus is idle. If any data is missing, communication will be re-initiated.

[0066] In the event of data loss, this invention re-initiates communication, specifically by re-transmitting multiple communication requests to the corresponding virtual public address in the preset configuration table. This allows the slave device to re-monitor the virtual public address for any communication requests requiring its response. After batch transmission, the transmission module confirms data reception with each device, marking and reporting any devices that haven't received data. The module then marks the data validity of the marked slave devices in the configuration table, with 0 indicating written data and 1 indicating not written data. The master device can then use the data markings in the configuration table to pinpoint the slave devices that haven't received data and resend targeted communication requests to them, avoiding the need to transmit all communication requests. This prevents resource waste and improves bus utilization.

[0067] It should also be noted that this invention also improves the security of the internal bus network by periodically updating the internal virtual address configuration table to replace the virtual address values.

[0068] Step S14: Obtain multiple response results corresponding to multiple communication requests returned in batches from the same group of slave devices.

[0069] In this embodiment of the invention, the slave device performs corresponding response operations to obtain response results, and returns the response results to the master device. The master device obtains multiple response results corresponding to multiple communication requests returned in batches by the same group of slave devices, thereby completing the communication. After the communication is completed, the system will also reset to the initial state, waiting for the next communication.

[0070] Beneficial effects: This invention, by setting up a virtual common address translation mechanism, allows the master device to detect current communication requests on the bus. It first determines whether the current communication request includes multiple communication requests targeting the same group of slave devices. If so, it uses the virtual common address to send these multiple communication requests in a single batch. This improves bus utilization, and the presence of the virtual common address also enhances communication security.

[0071] As described in the previous embodiment, this invention establishes a management table on the I2C communication link to group register addresses with the same configuration strategy. After the management table is established, a virtual address not existing on the bus is assigned to the group's configuration strategy, and data packets are sent to that virtual address. Slave devices in the same group obtain the corresponding virtual address after the configuration table is established, listen for data packets from that virtual address, and request batch communication based on the data packet request. The specific data communication process will be described in detail below.

[0072] This invention integrates a management module onto the bus. The management module can be integrated into the master device or served by a separate device with storage capabilities. The initial configuration table is manually entered and recorded via master-slave communication. The management module completes register grouping and virtual address generation based on the configuration information, and performs a series of configuration procedures. The management module includes an internal register, a processing module, and a transmission module. The processing and transmission modules are connected to the I2C bus. The processing module is responsible for automatically grouping and generating virtual addresses based on the configuration information, and storing the configuration information and virtual address-related information in the internal register. After initialization, the processing module listens for communication related to virtual addresses and records the corresponding status of the slave devices. The internal register stores grouping information and the virtual address generated for that group. The transmission module assists the processing module in confirming data with each group of slave devices; simultaneously, this module receives bus data transmission information and transmits it to the processing module for analysis.

[0073] See Figure 4 As shown, after system link initialization, the master and slave devices power on and prepare based on their respective configurations. The management module loads the initial configuration, mainly through manual input of configuration information. After input, a configuration file is generated as shown below. Figure 3 The configuration table shown is grouped according to the same device. Device 1 and device 2 are grouped together and generated virtual address 0x88. Device 3 and device 4 are grouped together and generated virtual address 0x78. Since the internal register addresses of 3 and 4 are different, a second-order virtual address 0x02 is generated.

[0074] After the configuration table is generated, the transmission module writes the virtual address information into each slave device. In addition to listening to its own real address data, the slave device also listens for virtual address data packets. When there is an I2C communication request on the bus, the master device listens to and parses the data packet to determine whether it is a request that can be accessed in batches within a group. Specifically, this involves comparing the slave device address in the communication data with the data in its internal registers.

[0075] For non-batch access requests, communication is not interfered with, and data packets are sent normally. For batch data requests, data is transmitted according to the virtual address based on the relevant information in the internal registers. When a slave device detects its own virtual address request, it will respond with an ACK and complete data reception. The management module will confirm that the slave device has completed data reception when the bus is idle. If any data is missing, communication will be re-initiated. After communication is completed, the system resets to its initial state and waits for the next communication. Simultaneously, this invention effectively improves the security of the internal bus network by periodically updating the internal virtual address configuration table and replacing the virtual address values.

[0076] Beneficial effects: This invention introduces a virtual address mechanism into the underlying hardware bus network and establishes a batch read / write strategy to improve bus utilization and stability.

[0077] See Figure 5 As shown, an embodiment of the present invention provides a data communication device applied to a main device, comprising:

[0078] The communication request acquisition module 11 is used to listen to the target bus in order to obtain the current communication requests on the target bus;

[0079] The determination module 12 is used to compare the slave device address carried in the current communication request with the slave device address in the preset configuration table to determine whether the current communication request includes multiple communication requests for the same group of slave devices; the preset configuration table is used to record the slave device addresses of several groups of slave devices and their corresponding virtual common addresses, with each group of slave devices corresponding to a different virtual common address;

[0080] The communication request transmission module 13 is used to transmit multiple communication requests to the corresponding virtual public address in the preset configuration table if the current communication request includes multiple communication requests for the same group of slave devices. This allows the slave devices in the same group to perform corresponding response operations after listening to the communication request that requires their own response on the virtual public address, so as to obtain the response result.

[0081] The response result acquisition module 14 is used to acquire multiple response results corresponding to multiple communication requests returned in batches by the same group of slave devices.

[0082] Since the embodiments of the device part correspond to the embodiments described above, please refer to the embodiments described in the method part for the embodiments of the device part, and will not be repeated here.

[0083] Beneficial effects: This invention, by setting up a virtual common address translation mechanism, allows the master device to detect current communication requests on the bus. It first determines whether the current communication request includes multiple communication requests targeting the same group of slave devices. If so, it uses the virtual common address to send these multiple communication requests in a single batch. This improves bus utilization, and the presence of the virtual common address also enhances communication security.

[0084] Furthermore, embodiments of this application also disclose an electronic device, Figure 6This is a structural diagram of an electronic device according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application. Specifically, the electronic device may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the data communication method disclosed in any of the foregoing embodiments. Furthermore, the electronic device in this embodiment may specifically be an electronic computer.

[0085] In this embodiment, the power supply 23 is used to provide operating voltage for various hardware devices on the electronic device; the communication interface 24 can create a data transmission channel between the electronic device and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0086] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0087] The operating system 221 is used to manage and control the various hardware devices on the electronic device and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including computer programs capable of performing the data communication methods executed by the electronic device as disclosed in any of the foregoing embodiments, the computer program 222 may further include computer programs capable of performing other specific tasks.

[0088] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned disclosed data communication method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.

[0089] Furthermore, this application also discloses a computer program product, including a computer program / instructions; wherein, when the computer program / instructions are executed by a processor, they implement the aforementioned disclosed response transmission method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.

[0090] 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 the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0091] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0092] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0093] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0094] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A data communication method, characterized in that, Applied to main components, including: Listen to the target bus to obtain the current communication requests on the target bus; The slave device address carried in the current communication request is compared with the slave device address in the preset configuration table to determine whether the current communication request includes multiple communication requests for the same group of slave devices; the preset configuration table is used to record the slave device addresses of several groups of slave devices and their corresponding virtual public addresses, with each group of slave devices corresponding to a different virtual public address; If the current communication request includes multiple communication requests for the same group of slave devices, then the multiple communication requests are transmitted to the corresponding virtual public address in the preset configuration table, so that after the slave devices in the same group detect that there is a communication request on the virtual public address that requires their own response, they perform the corresponding response operation to obtain the response result. Obtain multiple response results corresponding to the multiple communication requests returned in batches by the same group of slave devices.

2. The data communication method according to claim 1, characterized in that, Before comparing the slave device address carried in the current communication request with the slave device address in the preset configuration table, the method further includes: The slave devices are grouped according to their type, and the group number corresponding to each group of slave devices is determined; slave devices in the same group have the same type. Determine whether the internal register addresses corresponding to the slave devices in the same group are the same; If the internal register addresses of all slave devices in the same group are the same, then a virtual common address is randomly generated for each slave device in the same group to obtain a virtual common slave device address. If the internal register addresses of the slave devices in the same group are different, then a virtual common address corresponding to each internal register of each slave device in the same group is generated based on the internal register address of any slave device in the same group, so as to obtain the virtual common register address; The preset configuration table is constructed based on the group number, slave device address, internal register address of each slave device, virtual common slave device address, and virtual common register address of each slave device.

3. The data communication method according to claim 2, characterized in that, If the current communication request includes multiple communication requests for the same group of slave devices, then transmitting the multiple communication requests to the corresponding virtual public address in the preset configuration table includes: If the current communication request includes multiple communication requests for the same group of slave devices, and the internal register addresses corresponding to each slave device in the same group are the same, then the multiple communication requests will be transmitted to the corresponding virtual common slave device address in the preset configuration table. If the current communication request includes multiple communication requests for the same group of slave devices, and the internal register addresses corresponding to each slave device in the same group are different, then the multiple communication requests will be transmitted to the corresponding virtual common register address in the preset configuration table.

4. The data communication method according to claim 2, characterized in that, The step of comparing the slave device address carried in the current communication request with the slave device address in the preset configuration table to determine whether the current communication request includes multiple communication requests for the same group of slave devices includes: Compare the slave device address carried in the current communication request with the slave device address in the preset configuration table; If the addresses of each slave device carried in the current communication request are the same as the corresponding slave device addresses in the same group of slave devices in the preset configuration table, then it is determined that the current communication request includes multiple communication requests for the same group of slave devices. Otherwise, it is determined that the current communication request does not include multiple communication requests for the same group of slave devices.

5. The data communication method according to claim 4, characterized in that, After determining whether the current communication request includes multiple communication requests for the same group of slave devices, the process further includes: If the current communication request does not include multiple communication requests for the same group of slave devices, the current communication request is directly sent to the corresponding slave device according to the slave device address carried in the current communication request, so that after the slave device receives the communication request to respond to, it performs the corresponding response operation and returns the corresponding response result to the master device.

6. The data communication method according to any one of claims 1 to 5, characterized in that, The process of a slave device in the same group of slave devices, after detecting a communication request on the virtual public address that requires its own response, performing the corresponding response operation to obtain the response result, also includes: When the target bus is idle, determine whether the slave device has completed receiving the current communication request; If the slave device completes the reception of the current communication request, it determines whether the received communication request is complete and obtains the corresponding determination result, so that the slave device can perform the corresponding response operation based on the determination result to obtain the response result.

7. The data communication method according to claim 6, characterized in that, The step of obtaining the corresponding judgment result, so that the slave device can perform a corresponding response operation based on the judgment result to obtain the response result, includes: If the received communication request is complete, the slave device in the same group of slave devices will perform the corresponding response operation on the communication request that requires a response on the virtual public address to obtain the response result; If the received communication request is incomplete, the process jumps back to the step of transmitting the multiple communication requests to the corresponding virtual public address in the preset configuration table, so that the slave device can listen again for communication requests that require its response on the virtual public address.

8. A data communication device, characterized in that, Applied to main components, including: The communication request acquisition module is used to listen to the target bus in order to obtain the current communication requests on the target bus; The determination module is used to compare the slave device address carried in the current communication request with the slave device address in the preset configuration table to determine whether the current communication request includes multiple communication requests for the same group of slave devices; the preset configuration table is used to record the slave device addresses of several groups of slave devices and their corresponding virtual public addresses, with each group of slave devices corresponding to a different virtual public address; The communication request transmission module is used to transmit multiple communication requests to the corresponding virtual public address in the preset configuration table if the current communication request includes multiple communication requests for the same group of slave devices. This allows the slave devices in the same group to perform corresponding response operations after listening to the existence of a communication request that requires their own response on the virtual public address, so as to obtain a response result. The response result acquisition module is used to acquire multiple response results returned in batches by the same group of slave devices, corresponding to the multiple communication requests.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the data communication method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the data communication method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and device for allocating bus address to slave station, electronic equipment and storage medium

    CN117812044A

  • Data protection method and device, equipment and storage medium

    CN119004499A