CN114936180A - Automatic generation method and device for serial bus equipment address and storage medium - Google Patents

Automatic generation method and device for serial bus equipment address and storage medium Download PDF

Info

Publication number
CN114936180A
CN114936180A CN202210698801.4A CN202210698801A CN114936180A CN 114936180 A CN114936180 A CN 114936180A CN 202210698801 A CN202210698801 A CN 202210698801A CN 114936180 A CN114936180 A CN 114936180A
Authority
CN
China
Prior art keywords
address
information packet
slave device
target
slave
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210698801.4A
Other languages
Chinese (zh)
Inventor
马杰
黄亮
李建池
刘炜
吴志祥
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Zhierzhuo Digital Technology Co ltd
Original Assignee
Suzhou Zhierzhuo Digital Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Zhierzhuo Digital Technology Co ltd filed Critical Suzhou Zhierzhuo Digital Technology Co ltd
Priority to CN202210698801.4A priority Critical patent/CN114936180A/en
Publication of CN114936180A publication Critical patent/CN114936180A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0002Serial port, e.g. RS232C
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0016Inter-integrated circuit (I2C)

Abstract

The application discloses a method, a device and a storage medium for automatically generating serial bus equipment addresses, which relate to the technical field of serial communication, and the method comprises the following steps: receiving an information packet sent by a slave device; detecting whether the address in the information packet is a default address; if the address in the information packet is the default address, allocating a target address to the slave device according to an address allocation table, wherein the target address is used for indicating the slave device to record the target address and sending the information packet according to the target address, and the target address is different from the address allocated by the master device to other slave devices; and processing the information packet. The problem that address allocation complexity of the slave device is high and address conflict is easy to occur in the prior art is solved, and the effects that when the slave device sends a packet for the first time, the master device can efficiently allocate addresses to the slave device through the default addresses, the address allocation complexity is reduced, and the conflict is avoided are achieved.

Description

Automatic generation method and device for serial bus equipment address and storage medium
Technical Field
The invention relates to an automatic generation method and device of serial bus equipment address and a storage medium, belonging to the technical field of serial communication.
Background
In a master-slave serial communication system, allocating slave device addresses is a tedious task, and in the prior art, the addresses of the slave devices are usually set in a field dial-up/jumper manner, or an address value is preset in the slave devices in a software manner.
In the existing scheme, when a new slave device is accessed in a serial system, the complexity of address configuration for the new slave device is high, and address conflict is easy to occur.
Disclosure of Invention
The invention aims to provide a method and a device for automatically generating serial bus equipment addresses and a storage medium, which are used for solving the problems in the prior art.
In order to achieve the purpose, the invention provides the following technical scheme:
according to a first aspect, an embodiment of the present invention provides an automatic generation method for serial bus device addresses, where the method is used in a master device, and the method includes:
receiving an information packet sent by a slave device;
detecting whether the address in the information packet is a default address;
if the address in the information packet is the default address, allocating a target address to the slave device according to an address allocation table, wherein the target address is used for indicating the slave device to record the target address and sending the information packet according to the target address, and the target address is different from the address allocated by the master device to other slave devices;
and processing the information packet.
Optionally, the receiving the information packet sent by the slave device includes:
and receiving the information packet carrying the default address sent by the slave device when the slave device is accessed to a serial bus system or receives a preset trigger operation.
Optionally, the method further comprises:
detecting whether the address allocation table overflows or not;
and if the address allocation table overflows, sending alarm prompt information.
Optionally, after allocating the target address to the slave device according to the address allocation table, the method further includes:
receiving confirmation information returned by the slave equipment;
after receiving the acknowledgement information, marking the target address in the address allocation table as allocated.
Optionally, if the address in the packet is not the default address, the step of processing the packet is performed.
Optionally, if the address in the packet is not the default address, detecting whether the address in the packet is an address already allocated in the address allocation table;
and if the address is the address allocated in the address allocation table, executing the step of processing the information packet.
Optionally, the method further comprises:
sending a target information packet to a serial bus, wherein the target information packet carries the target address; and the slave equipment judges whether to process the target information packet according to the target address.
Optionally, the method further comprises:
acquiring the running state of a serial bus system;
if the representation of the running state needs to carry out public control on each slave device, acquiring a corresponding special address according to the running state;
and sending the public information packet carrying the special address to a serial bus.
In a second aspect, an apparatus for automatically generating serial bus device addresses is provided, the apparatus includes a memory and a processor, the memory stores at least one program instruction, and the processor loads and executes the at least one program instruction to implement the method according to the first aspect.
In a third aspect, a computer storage medium is provided, having stored therein at least one program instruction that is loaded and executed by a processor to implement the method of the first aspect.
By receiving a packet sent from a device; detecting whether the address in the information packet is a default address; if the address in the information packet is the default address, allocating a target address to the slave device according to an address allocation table, wherein the target address is used for indicating the slave device to record the target address and sending the information packet according to the target address, and the target address is different from the address allocated to other slave devices by the master device; and processing the information packet. The problem that address allocation complexity of the slave device is high and address conflict is easy to occur in the prior art is solved, and the effects that when the slave device sends a packet for the first time, the master device can efficiently allocate addresses to the slave device through the default addresses, the address allocation complexity is reduced, and the conflict is avoided are achieved. In addition, in the application, only when the slave device sends the information packet for the first time, the master device adds the step of address allocation, and the communication efficiency of the subsequent serial bus is not influenced.
In the application, the master device allocates the addresses for the slave devices according to the address allocation table, so that the concealment of the addresses of the slave devices is improved, and the external intrusion resistance is improved.
The foregoing description is only an overview of the technical solutions of the present invention, and in order to make the technical solutions of the present invention more clearly understood and to make the technical solutions of the present invention practical in accordance with the contents of the specification, the following detailed description is given of preferred embodiments of the present invention with reference to the accompanying drawings.
Drawings
Fig. 1 is a flowchart of a method for automatically generating an address of a serial bus device according to an embodiment of the present invention;
fig. 2 and 3 are schematic diagrams of a master device allocating a target address to a slave device according to an embodiment of the present invention.
Detailed Description
The technical solutions of the present invention will be described clearly and completely with reference to the accompanying drawings, and it should be understood that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, and are only for convenience of description and simplicity of description, but do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus, should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
In the description of the present invention, it should be noted that, unless otherwise explicitly specified or limited, the terms "mounted," "connected," and "connected" are to be construed broadly, e.g., as meaning either a fixed connection, a removable connection, or an integral connection; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meanings of the above terms in the present invention can be understood in specific cases to those skilled in the art.
In addition, the technical features involved in the different embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
Referring to fig. 1, a flowchart of a method for automatically generating an address of a serial bus device according to an embodiment of the present application is shown, where as shown in fig. 1, the method includes:
step 101, receiving an information packet sent by slave equipment;
after accessing the serial bus, the slave device may send a packet to the master device via the serial bus. The Serial bus may be a Serial Peripheral Interface (SPI) or an I 2 C (bidirectional two-wire system synchronous serial bus) and RS232, RS422, RS485 and other forms based on UART (Universal Asynchronous Receiver/Transmitter) physical type. Accordingly, the slave device may receive the packet.
In the application, when the slave device first accesses the serial bus system, an information packet carrying a default address may be sent to the master device. In actual implementation, after the slave device accesses the serial bus, the slave device may also send an information packet carrying a default address to the master device when receiving a preset trigger operation. The preset trigger operation may be one or more of a key operation, a touch operation, a voice control operation, and other types of operations, which is not limited herein.
The default address is an address predetermined by the master device and the slave device, and may be a single byte or multiple bytes, for example, the default address may be 00H, 0000H, or the like, and the address length of the default address may be set according to a system memory of the serial bus, which is not limited.
102, detecting whether an address in the information packet is a default address;
after receiving the information packet, the master device analyzes the address carried in the information packet and detects whether the address in the information packet is a default address.
103, if the address in the information packet is the default address, allocating a target address to the slave device according to an address allocation table;
if the detection result is that the address in the packet is the default address, it indicates that the master device does not assign an address to the slave device, and at this time, the master device may assign a target address to the slave device according to the address assignment table. The target address is used for indicating the slave equipment to record the target address and sending an information packet according to the target address, and the target address is different from addresses distributed by the master equipment to other slave equipment.
The address allocation table includes addresses and allocation states of the addresses. In this step, the master device assigns an address marked as "unassigned" to the slave device according to the assignment status of each address.
In practical implementation, a part of special addresses may be reserved in the serial bus system, and the special addresses may be reserved for special devices, or may be used as a primary common command, a special call sign, or the like, so that the slave device performs a related appointed action after receiving the special addresses. In one possible embodiment, please refer to table 1, which illustrates one possible implementation of the address allocation table.
Figure BDA0003703723000000061
Figure BDA0003703723000000071
TABLE 1
When allocating an address to a slave device, the master device may sequentially fetch addresses marked as "unallocated" from the address allocation table and assign the addresses to the corresponding slave devices. For example, referring to fig. 2 and 3, in one possible implementation, the master device and the slave devices 0# to n # connected to the serial bus, the packet is the boot code, the address value, the data/character string, and the default address of the slave device is 00H, and if the 0# slave device first sends the packet to the master device, the master device assigns the address value of the 0# slave device to 0 AH. Similarly, if the 1# slave sends a packet to the master second, the master will assign a 0# slave address value of 0 BH. In actual implementation, if the second 5# slave device sends a packet to the master device, the master device assigns the address value of the 5# slave device to be 0BH, which is not described herein again in this embodiment.
After the master device assigns a target address to the slave device, the master device may send the assigned target address to the slave device through the serial bus, and accordingly, the slave device may receive the target address, and thereafter, the method may further include: receiving confirmation information returned by the slave equipment; after receiving the acknowledgement information, marking the target address in the address allocation table as allocated.
For example, the slave replies to the master with a string of special characters, such as "Addr _ OK," indicating that address assignment between the master and slave is complete, the slave is registered, the slave records the destination address, and then sends a packet based on the destination address.
In a possible implementation manner, when the master device allocates an address according to the address allocation table, the following steps may be further performed: detecting whether the address allocation table overflows or not; and if the address allocation table overflows, sending alarm prompt information. Otherwise, if the address allocation table does not overflow, step 101 is continuously executed, which is not described herein again.
And 104, processing the information packet.
The master device may process the control instructions or data in the packet.
In this embodiment, the master device may further perform the following steps:
firstly, acquiring the running state of a serial bus system;
secondly, if the representation of the running state needs to carry out common control on each slave device, acquiring a corresponding special address according to the running state;
the common control may include: at least one of global start, global stop, global pause, global resume, global alert, global silence. Referring to table 1, when the master device detects that the current operating state requires global startup of all the slave devices, the special address corresponding to the operating state may be obtained as 01H according to table 1.
On the contrary, if the obtained operation state is to send the packet to a certain slave device, the packet may be sent according to the history of the address allocated to the slave device, which is not described herein again.
And thirdly, sending the public information packet carrying the special address to a serial bus.
After the master device acquires the special address, the master device can send a public information packet carrying the special address to the serial bus, each slave device analyzes the address after receiving the information packet on the serial bus, and if the address is the own address or the special address, the slave device processes the address, otherwise, the slave device discards the information packet. In this scenario, when the address carried in the public information packet is obtained through analysis and is 01H, each slave device may start. Similarly, other slave devices can be started all together, so that the effect of starting all the slave devices all together is achieved.
In summary, by receiving the information packet sent by the slave device; detecting whether the address in the information packet is a default address; if the address in the information packet is the default address, allocating a target address to the slave device according to an address allocation table, wherein the target address is used for indicating the slave device to record the target address and sending the information packet according to the target address, and the target address is different from the address allocated to other slave devices by the master device; and processing the information packet. The problem that address allocation complexity of the slave device is high and address conflict is easy to occur in the prior art is solved, and the effects that when the slave device sends a packet for the first time, the master device can efficiently allocate addresses to the slave device through the default addresses, the address allocation complexity is reduced, and the conflict is avoided are achieved. In addition, in the application, only when the slave device sends the information packet for the first time, the master device adds the step of address allocation, and the communication efficiency of the subsequent serial bus is not influenced.
In the application, the master device allocates the address for the slave device according to the address allocation table, so that the concealment of the address of the slave device is improved, and the external intrusion resistance is improved.
In the above embodiment, the method may further include:
and if the address in the information packet is not the default address, executing the step of processing the information packet.
Specifically, if the address in the information packet is not the default address, detecting whether the address in the information packet is an address already allocated in the address allocation table;
and if the address is allocated in the address allocation table, executing the step of processing the information packet. If not, the packet is discarded and step 101 is continued.
The application also provides an automatic generation device of serial bus device address, which comprises a memory and a processor, wherein at least one program instruction is stored in the memory, and the processor loads and executes the at least one program instruction to realize the method.
The present application also provides a computer storage medium having stored therein at least one program instruction, which is loaded and executed by a processor to implement the method as described above.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that various changes and modifications can be made by those skilled in the art without departing from the spirit of the invention, and these changes and modifications are all within the scope of the invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A method for automatically generating serial bus device addresses, which is used in a master device, and comprises the following steps:
receiving an information packet sent by a slave device;
detecting whether the address in the information packet is a default address;
if the address in the information packet is the default address, allocating a target address to the slave device according to an address allocation table, wherein the target address is used for indicating the slave device to record the target address and sending the information packet according to the target address, and the target address is different from the address allocated by the master device to other slave devices;
and processing the information packet.
2. The method of claim 1, wherein receiving the information packet sent from the device comprises:
and receiving the information packet carrying the default address sent by the slave device when the slave device is accessed to a serial bus system or receives a preset trigger operation.
3. The method of claim 1, further comprising:
detecting whether the address allocation table overflows or not;
and if the address allocation table overflows, sending alarm prompt information.
4. The method of claim 1, wherein after the slave device is assigned the target address according to an address assignment table, the method further comprises:
receiving confirmation information returned by the slave equipment;
after receiving the acknowledgement information, marking the target address in the address allocation table as allocated.
5. The method of claim 1,
and if the address in the information packet is not the default address, executing the step of processing the information packet.
6. The method of claim 5,
if the address in the information packet is not the default address, detecting whether the address in the information packet is the address allocated in the address allocation table;
and if the address is the address allocated in the address allocation table, executing the step of processing the information packet.
7. The method of any of claims 1 to 6, further comprising:
sending a target information packet to a serial bus, wherein the target information packet carries the target address; and the slave equipment judges whether to process the target information packet according to the target address.
8. The method of any of claims 1 to 6, further comprising:
acquiring the running state of a serial bus system;
if the operating state representation needs to carry out common control on each slave device, acquiring a corresponding special address according to the operating state;
and sending the public information packet carrying the special address to a serial bus.
9. An apparatus for automatically generating serial bus device addresses, the apparatus comprising a memory and a processor, the memory having at least one program instruction stored therein, the processor implementing the method according to any one of claims 1 to 8 by loading and executing the at least one program instruction.
10. A computer storage medium having stored therein at least one program instruction which is loaded and executed by a processor to implement the method of any one of claims 1 to 8.
CN202210698801.4A 2022-06-20 2022-06-20 Automatic generation method and device for serial bus equipment address and storage medium Pending CN114936180A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210698801.4A CN114936180A (en) 2022-06-20 2022-06-20 Automatic generation method and device for serial bus equipment address and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210698801.4A CN114936180A (en) 2022-06-20 2022-06-20 Automatic generation method and device for serial bus equipment address and storage medium

Publications (1)

Publication Number Publication Date
CN114936180A true CN114936180A (en) 2022-08-23

Family

ID=82869177

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210698801.4A Pending CN114936180A (en) 2022-06-20 2022-06-20 Automatic generation method and device for serial bus equipment address and storage medium

Country Status (1)

Country Link
CN (1) CN114936180A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101631148A (en) * 2009-08-21 2010-01-20 上海奈凯电子科技有限公司 Communication method for allocating dynamic addresses in serial communication protocols
CN101834912A (en) * 2010-04-20 2010-09-15 南京航空航天大学 Device for dynamically allocating slave addresses in pair of multistandard serial communications and use method
US20100306431A1 (en) * 2009-05-28 2010-12-02 Christopher Alan Adkins Dynamic Address Change for Slave Devices on a Shared Bus
WO2014209368A1 (en) * 2013-06-28 2014-12-31 Schneider Electric It Corporation System and method for automatically addressing devices in a multi-drop master/slave network
CN112583677A (en) * 2019-09-30 2021-03-30 成都鼎桥通信技术有限公司 Method, device, storage medium and system for allocating addresses to slave devices
CN114338610A (en) * 2021-11-22 2022-04-12 广州极飞科技股份有限公司 Address allocation method, equipment management and irrigation system and slave equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100306431A1 (en) * 2009-05-28 2010-12-02 Christopher Alan Adkins Dynamic Address Change for Slave Devices on a Shared Bus
CN101631148A (en) * 2009-08-21 2010-01-20 上海奈凯电子科技有限公司 Communication method for allocating dynamic addresses in serial communication protocols
CN101834912A (en) * 2010-04-20 2010-09-15 南京航空航天大学 Device for dynamically allocating slave addresses in pair of multistandard serial communications and use method
WO2014209368A1 (en) * 2013-06-28 2014-12-31 Schneider Electric It Corporation System and method for automatically addressing devices in a multi-drop master/slave network
CN112583677A (en) * 2019-09-30 2021-03-30 成都鼎桥通信技术有限公司 Method, device, storage medium and system for allocating addresses to slave devices
CN114338610A (en) * 2021-11-22 2022-04-12 广州极飞科技股份有限公司 Address allocation method, equipment management and irrigation system and slave equipment

Similar Documents

Publication Publication Date Title
CN108804938B (en) Authority detection method and device, electronic equipment and readable storage medium
CN111294416A (en) Method for obtaining IP address and related product
CN114650273A (en) Initialization method, device, equipment and storage medium for operating system configuration
CN112055066B (en) Communication method, communication device, diagnosis device, and computer-readable storage medium
CN114936180A (en) Automatic generation method and device for serial bus equipment address and storage medium
WO2020113478A1 (en) Address information processing method and apparatus, electronic device, and storage medium
EP4351279A1 (en) Control method, control device and lighting system
CN108446144B (en) Application program starting method and device, terminal and storage medium
CN107911816B (en) Starting method for multi-mode IoT device, multi-mode IoT device and storage medium
CN115454896A (en) SMBUS-based SSD MCTP control message verification method and device, computer equipment and storage medium
CN112367256B (en) Creation method, device and storage medium
JP5119204B2 (en) Programmable controller, data writing method, and receiving module
CN115174524A (en) Floating IP distribution method, device, electronic equipment and storage medium
CN112615916A (en) File deployment method and device, electronic equipment and storage medium
CN113760325A (en) Container environment updating method and device
CN111711714A (en) IP address query method, device, server, control equipment and medium
CN113949628B (en) Automatic equipment adding method and system
CN114157995B (en) Bluetooth networking method, bluetooth networking device, electronic equipment and computer readable storage medium
CN112260914B (en) Virtual Modbus ID generation method and device and gateway
CN115333933B (en) Automatic management method, medium and equipment for servers on machine room
CN114500469B (en) Automatic identification and address allocation method for intelligent electric equipment
JP2019139417A (en) Information processing apparatus, control method, and control program
CN113949628A (en) Automatic adding method and system for equipment
CN115397033B (en) Wireless communication method, wireless communication device, wireless communication module, medium, and program product
CN113141367B (en) Control method, device and storage medium for terminal equipment to access network

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination