CN111597123A - Automatic address allocation method, device, computer equipment and storage medium - Google Patents

Automatic address allocation method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN111597123A
CN111597123A CN202010270890.3A CN202010270890A CN111597123A CN 111597123 A CN111597123 A CN 111597123A CN 202010270890 A CN202010270890 A CN 202010270890A CN 111597123 A CN111597123 A CN 111597123A
Authority
CN
China
Prior art keywords
slave
address
machine
master
frame data
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.)
Granted
Application number
CN202010270890.3A
Other languages
Chinese (zh)
Other versions
CN111597123B (en
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.)
Guangdong Chigo Heating and Ventilation Equipment Co Ltd
Original Assignee
Guangdong Chigo Heating and Ventilation Equipment 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 Guangdong Chigo Heating and Ventilation Equipment Co Ltd filed Critical Guangdong Chigo Heating and Ventilation Equipment Co Ltd
Priority to CN202010270890.3A priority Critical patent/CN111597123B/en
Publication of CN111597123A publication Critical patent/CN111597123A/en
Application granted granted Critical
Publication of CN111597123B publication Critical patent/CN111597123B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory

Abstract

The invention relates to the technical field of RS485 communication, in particular to a method and a device for automatically allocating addresses, computer equipment and a storage medium. The method comprises the following steps: the master machine sends first frame data to each slave machine; if the master machine receives a reply frame of a first slave machine, the first slave machine is one of the slave machines, the master machine sends second frame data to each slave machine, the second frame data comprises the master machine address and the target slave machine address, and the second frame data is used for the first slave machine to determine that the slave machine address of the first slave machine is only used by the first slave machine, so that address allocation is completed. The slave machine generates the address of the slave machine per se, and then the address of the slave machine per se is determined to be only used by the slave machine per se by receiving the first frame data and the second frame data sent by the host machine, so that the address of the slave machine is not required to be well allocated by the host machine and then sent to the slave machine, the address allocation efficiency is improved, and the problems that the host machine needs to occupy resources to process address allocation and the address allocation efficiency is low are solved.

Description

Automatic address allocation method, device, computer equipment and storage medium
Technical Field
The invention relates to the technical field of RS485 communication, in particular to a method and a device for automatically allocating addresses, computer equipment and a storage medium.
Background
The RS485 communication system sends a corresponding address allocation command to the master machine in a specific time, the slave machines receive the address allocation command, and then address allocation is completed through a series of communication actions of the master machine and the slave machines. Therefore, the host allocates the address of the slave and then sends the address to the slave, and the slave performs allocation according to the received address, so that the host needs to occupy resources to process address allocation, and the address allocation efficiency is low.
Disclosure of Invention
Aiming at the defects of the prior art, the invention provides a method and a device for automatically allocating addresses, computer equipment and a storage medium, aiming at solving the problems that a host needs to occupy resources to process address allocation and the address allocation efficiency is low.
The technical scheme provided by the invention is as follows:
a method of automatically assigning addresses, the method comprising:
the method comprises the steps that a master machine sends first frame data to each slave machine, wherein the first frame data comprise a master machine address and a target slave machine address, the master machine can receive a reply frame sent by one slave machine according to the master machine address due to the fact that the address of the slave machine per se is consistent with the address of the target slave machine, but cannot receive reply frames sent by more than two slave machines according to the master machine address due to the fact that the address of the slave machine per se is consistent with the address of the target slave machine;
if the master receives a reply frame of a first slave, the master sends second frame data to each slave, the second frame data comprises the master address and the target slave address, the second frame data is used for the first slave to determine that the slave address of the first slave is only used by the first slave, and address allocation is completed, wherein the first slave is one of the slaves.
Further, after the step of sending the first frame data to the slaves by the master, the method includes:
and if the master does not receive the reply frame of any slave of the slaves, the master sends new first frame data to the slaves, wherein the new first frame data comprises the master address and a new target slave address.
Further, after the step of sending, by the master, the second frame data to the slaves if the master receives the reply frame of the first slave, the method includes:
and the master machine sends new first frame data to each slave machine until each slave machine finishes address allocation or until the address in the address pool range finishes polling, wherein the new first frame data comprises the master machine address and a new target slave machine address.
The invention also provides an automatic address allocation method, which comprises the following steps:
the method comprises the steps that a first slave receives first frame data sent by a master to each slave, extracts a target slave address from the first frame data, and judges whether the target slave address is consistent with the slave address of the first slave, wherein the first frame data comprises the master address and the target slave address, and the first slave is one of the slaves;
if the first slave machine judges that the target slave machine address is consistent with the own slave machine address, the first slave machine sends a reply frame to the host machine according to the host machine address;
the first slave machine receives second frame data sent by the master machine to each slave machine, extracts the target slave machine address from the second frame data, and judges whether the target slave machine address is consistent with the slave machine address of the first slave machine, wherein the second frame data comprises the master machine address and the target slave machine address;
and if the first slave determines that the target slave address is consistent with the self slave address, the first slave determines that the self slave address is only used by the first slave, and the address allocation is finished.
Further, the method includes, after the step of receiving first frame data transmitted from a master to each slave by the first slave, extracting a target slave address from the first frame data, and determining whether the target slave address matches the own slave address, the method including:
if a first slave machine judges that the target slave machine address is consistent with the own slave machine address, the first slave machine sends a reply frame to the master machine according to the master machine address, wherein in addition to the first slave machine sending the reply frame, more than one slave machine sending the reply frame exist in each slave machine;
the first slave machine does not receive second frame data, and the first slave machine generates own slave machine addresses again randomly, wherein the first slave machine and more than one other slave machine simultaneously send reply frames to the master machine according to the master machine addresses to generate signal interference, and the master machine cannot receive the reply frames sent by the first slave machine and more than one other slave machine.
Further, the step of the first slave not receiving the second frame data and the first slave randomly generating its own slave address again includes:
the first slave machine does not receive second frame data, and after the address in an address determination table is removed, the first slave machine randomly generates a slave machine address again, wherein the address determination table is a target slave machine address of the second frame data received before the first slave machine records, and an address list is generated according to the target slave machine address.
Further, before the step of receiving first frame data transmitted from a master to each slave by the first slave, extracting a target slave address from the first frame data, and determining whether the target slave address matches the own slave address, the method includes:
the first slave machine judges whether the current power-on is the first power-on;
and if the first slave machine judges that the current power-on is the first power-on, the first slave machine randomly generates the address of the slave machine per se in the address within the address pool range.
The invention also provides an automatic address allocation device, which comprises a host and/or a first slave;
the host includes:
the first sending module is used for sending first frame data to each slave machine by the master machine, wherein the first frame data comprises a master machine address and a target slave machine address, the master machine can receive a reply frame sent by one slave machine according to the master machine address due to the fact that the own slave machine address is consistent with the target slave machine address, but cannot receive reply frames sent by more than two slave machines according to the master machine address due to the fact that the own slave machine address is consistent with the target slave machine address;
a second sending module, configured to send, by the master device, second frame data to each slave device if the master device receives a reply frame of a first slave device, where the second frame data includes the master address and the target slave address, and the second frame data is used by the first slave device to determine that its own slave address is only used by itself, so as to complete address allocation, where the first slave device is one of the slave devices;
the first slave machine includes:
the first processing module is used for receiving first frame data sent by a master to each slave by a first slave, extracting a target slave address from the first frame data, and judging whether the target slave address is consistent with the slave address of the first slave, wherein the first frame data comprises the master address and the target slave address, and the first slave is one of the slaves;
a third sending module, configured to send, if the first slave determines that the target slave address is consistent with the own slave address, the first slave sends a reply frame to the master according to the master address;
the second processing module is used for the first slave machine to receive second frame data sent by the host machine to each slave machine, extract the target slave machine address from the second frame data and judge whether the target slave machine address is consistent with the slave machine address of the first slave machine, wherein the second frame data comprises the host machine address and the target slave machine address;
and the address determining module is used for determining that the address of the slave machine is only used by the first slave machine if the first slave machine determines that the target slave machine address is consistent with the address of the slave machine, so that the address allocation is completed.
The invention also provides a computer device comprising a memory storing a computer program and a processor implementing the steps of any of the above methods when the processor executes the computer program.
The invention also provides a computer-readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, carries out the steps of the method of any of the above.
According to the technical scheme, the invention has the beneficial effects that: the slave machine generates the address of the slave machine per se, and then the address of the slave machine per se is determined to be only used by the slave machine per se by receiving the first frame data and the second frame data sent by the host machine, so that the address of the slave machine is not required to be well allocated by the host machine and then sent to the slave machine, the address allocation efficiency is improved, and the problems that the host machine needs to occupy resources to process address allocation and the address allocation efficiency is low are solved.
Drawings
FIG. 1 is a flow chart of a method for automatically allocating addresses according to an embodiment of the present invention;
FIG. 2 is a flow chart of a method for automatically allocating addresses according to another embodiment of the present invention;
FIG. 3 is a functional block diagram of an apparatus for automatically allocating addresses according to an embodiment of the present invention;
FIG. 4 is a functional block diagram of an apparatus for automatically allocating addresses according to another embodiment of the present invention;
fig. 5 is a block diagram schematically illustrating a structure of a computer device to which an embodiment of the present invention is applied.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
As shown in fig. 1, an embodiment of the present invention provides a method for automatically allocating an address, where the method includes the following steps:
step S101, the master sends first frame data to each slave, where the first frame data includes a master address and a target slave address, and the master can receive a reply frame sent by one slave according to the master address because the own slave address is consistent with the target slave address, but cannot receive reply frames sent by two or more slaves according to the master address because the own slave address is consistent with the target slave address.
The first frame data may include a header, a trailer, and a checksum in addition to the host address and the target slave address. The header and trailer may identify whether the first frame of data is a complete frame of data. The check code is used to check whether the first frame data is correct. The target slave address is one of the addresses in the address pool range, the target slave address in the first frame data sent for the first time is the first one of the addresses in the address pool range in the order sequence, and the target slave address in the first frame data sent for the second time is the second one of the addresses in the address pool range in the order sequence.
In the present embodiment, the master can receive the reply frame transmitted from the master because the own slave address coincides with the target slave address, but cannot receive the reply frame transmitted from two or more slaves because the own slave address coincides with the target slave address. Because more than two slave machines simultaneously send reply frames to the master machine according to the master machine address, signal interference is generated, and the master machine cannot receive the reply frames sent by the slave machines.
Step S102, if the master receives a reply frame of a first slave, the master sends second frame data to each slave, where the second frame data includes the master address and the target slave address, and the second frame data is used by the first slave to determine that its own slave address is only used by itself, so as to complete address allocation, where the first slave is one of the slaves.
The first slave machine receives the first frame data and then receives the second frame data again, so that the first slave machine can determine that the slave machine address is only used by itself, does not repeat the address with other slave machines, does not need to change the address, and completes address allocation.
In some embodiments, in step S102, the method includes:
if the master receives a reply frame of a first slave within a first preset time, and the first slave is one of the slaves, the master sends second frame data to the slaves.
The master computer needs to receive the reply frame of the first slave computer within the first preset time to send the second frame data to each slave computer.
In the present embodiment, after step S102, the method includes:
and if the master does not receive the reply frame of any slave of the slaves, the master sends new first frame data to the slaves, wherein the new first frame data comprises the master address and a new target slave address.
If the master does not receive the reply frame, the target slave address is not considered to be used by the slave, or more than two slaves use the target slave address, the second frame data is not sent again, the first frame data is sent again, the first frame data sent at the moment is called as new first frame data because the target slave address of the first frame data sent at the moment is different from that of the first frame data sent before, and the target slave address in the new first frame data is called as a new target slave address.
In some embodiments, after step S102, the method includes:
if the master does not receive the reply frame of any slave of the slaves within the first preset time, the master sends new first frame data to the slaves, wherein the new first frame data comprises the master address and a new target slave address.
The master computer needs not to receive the reply frame of the first slave computer within the first preset time to send new first frame data to each slave computer.
In the present embodiment, after step S102, the method includes:
and the master machine sends new first frame data to each slave machine until each slave machine finishes address allocation or until the address in the address pool range finishes polling, wherein the new first frame data comprises the master machine address and a new target slave machine address.
And completing address allocation by adopting each slave machine or completing polling by adopting the addresses in the address pool range, and finishing the circulation. When the slave machines are adopted to complete address allocation, after each slave machine receives the second frame data, a reply frame needs to be sent to the host machine, so that the host machine can count whether the slave machines complete address allocation.
The slave machine generates the address of the slave machine per se, and then the address of the slave machine per se is determined to be only used by the slave machine per se by receiving the first frame data and the second frame data sent by the host machine, so that the address of the slave machine is not required to be well allocated by the host machine and then sent to the slave machine, the address allocation efficiency is improved, and the problems that the host machine needs to occupy resources to process address allocation and the address allocation efficiency is low are solved.
As shown in fig. 2, an embodiment of the present invention provides a method for automatically allocating an address, where the method includes:
step S201, a first slave receives first frame data sent by a master to each slave, extracts a target slave address from the first frame data, and determines whether the target slave address matches a slave address of the first slave, where the first frame data includes the master address and the target slave address, and the first slave is one of the slaves.
And each slave extracts a target slave address from the first frame data, acquires the own slave address, compares the target slave address with the own slave address, and judges whether the target slave address and the own slave address are consistent or not through comparison. The first slave is one of the slaves, and similarly, the first slave extracts the target slave address from the first frame data, acquires the own slave address, compares the target slave address with the own slave address, and judges whether the target slave address and the own slave address are consistent or not through comparison.
Step S202, if the first slave determines that the target slave address matches the own slave address, the first slave transmits a reply frame to the master according to the master address, where the first slave is one of the slaves.
If only one slave in the slaves determines that the target slave address is consistent with the own slave address, and the slave is the first slave, the first slave sends a reply frame to the master according to the master address, and the other slaves determine that the target slave address is inconsistent with the own slave address, and do not send the reply frame to the master.
Step S203, the first slave receives second frame data sent by the master to each slave, extracts the target slave address from the second frame data, and determines whether the target slave address matches the own slave address, where the second frame data includes the master address and the target slave address.
The master machine sends the second frame data to each slave machine after receiving the reply frame, each slave machine extracts the target slave machine address from the second frame data, then obtains the own slave machine address, compares the target slave machine address with the own slave machine address, and judges whether the target slave machine address and the own slave machine address are consistent through comparison.
Step S204, if the first slave determines that the target slave address matches the own slave address, the first slave determines that the own slave address is used only by itself, and completes address allocation.
In this case, only the first slave determines that the target slave address matches the own slave address, and the other slaves determine that the target slave address does not match the own slave address, and the first slave receives the first frame data and the second frame data, and performs determination twice to determine that the own slave address is used only by itself, thereby completing address allocation.
In some embodiments, in step S204, the method includes:
the first slave machine judges that the target slave machine address is consistent with the self slave machine address;
the first slave machine acquires a time interval between the reception of first frame data and second frame data;
the first slave machine judges whether the time interval is smaller than a preset time interval or not;
if so, the first slave machine determines that the address of the slave machine is only used by the first slave machine, and completes address allocation.
And determining that the first frame data and the second frame data are transmitted by the host at the same determined address by judging the time interval.
In the present embodiment, after step S201, the method includes:
if a first slave machine judges that the target slave machine address is consistent with the own slave machine address, the first slave machine sends a reply frame to the master machine according to the master machine address, wherein in addition to the first slave machine sending the reply frame, more than one slave machine sending the reply frame exist in each slave machine;
the first slave machine does not receive second frame data, and the first slave machine generates own slave machine addresses again randomly, wherein the first slave machine and more than one other slave machine simultaneously send reply frames to the master machine according to the master machine addresses to generate signal interference, and the master machine cannot receive the reply frames sent by the first slave machine and more than one other slave machine.
Two slaves of each extension judge that the target slave address is consistent with the slave address of the slave, of course, more than two slaves are also possible, the two slaves are respectively a first slave and a second slave, the first slave and the second slave both simultaneously send reply frames to the master according to the master address to generate signal interference, the master cannot receive the reply frames sent by the first slave and the second slave, and the master cannot send second frame data to the slaves. The re-randomly generated own slave address is also an address within the address pool.
In some embodiments, in the step that the first slave does not receive the second frame data, and the first slave randomly generates its own slave address again, the method includes:
the first slave machine does not receive second frame data, and after the address in an address determination table is removed, the first slave machine randomly generates a slave machine address again, wherein the address determination table is a target slave machine address of the second frame data received before the first slave machine records, and an address list is generated according to the target slave machine address.
After the address determination table exists in each slave, if the first slave does not receive the second frame data due to the fact that the first slave sends the reply frame, and the address of the first slave needs to be generated again, the address in the address determination table is removed, then the address of the first slave is generated again randomly, and the address of the second slave is also the address in the address pool range.
In the present embodiment, before step S201, the method includes:
the first slave machine judges whether the current power-on is the first power-on;
and if the first slave machine judges that the current power-on is the first power-on, the first slave machine randomly generates the address of the slave machine per se in the address within the address pool range.
The first power-on refers to the first power-on after leaving the factory, that is, the own slave address is not generated, and the slave has no own slave address.
The slave machine generates the address of the slave machine per se, and then the address of the slave machine per se is determined to be only used by the slave machine per se by receiving the first frame data and the second frame data sent by the host machine, so that the address of the slave machine is not required to be well allocated by the host machine and then sent to the slave machine, the address allocation efficiency is improved, and the problems that the host machine needs to occupy resources to process address allocation and the address allocation efficiency is low are solved.
As shown in fig. 3, an embodiment of the invention provides an apparatus for automatically allocating addresses, which includes a master 1 and/or a first slave 2.
The host 1 includes a first transmission module 11 and a second transmission module 12.
The first sending module 11 is configured to send first frame data to each slave, where the first frame data includes a master address and a target slave address, and the master is capable of receiving a reply frame sent by one slave according to the master address because the own slave address is identical to the target slave address, but is incapable of receiving reply frames sent by two or more slaves according to the master address because the own slave address is identical to the target slave address.
The first frame data may include a header, a trailer, and a checksum in addition to the host address and the target slave address. The header and trailer may identify whether the first frame of data is a complete frame of data. The check code is used to check whether the first frame data is correct. The target slave address is one of the addresses in the address pool range, the target slave address in the first frame data sent for the first time is the first one of the addresses in the address pool range in the order sequence, and the target slave address in the first frame data sent for the second time is the second one of the addresses in the address pool range in the order sequence.
In the present embodiment, the master can receive the reply frame transmitted from the master because the own slave address coincides with the target slave address, but cannot receive the reply frame transmitted from two or more slaves because the own slave address coincides with the target slave address. Because more than two slave machines simultaneously send reply frames to the master machine according to the master machine address, signal interference is generated, and the master machine cannot receive the reply frames sent by the slave machines.
A second sending module 12, configured to, if the master receives a reply frame of a first slave, send, by the master, second frame data to each slave, where the second frame data includes the master address and the target slave address, and the second frame data is used by the first slave to determine that its own slave address is only used by itself, so as to complete address allocation, where the first slave is one of the slaves.
The first slave machine receives the first frame data and then receives the second frame data again, so that the first slave machine can determine that the slave machine address is only used by itself, does not repeat the address with other slave machines, does not need to change the address, and completes address allocation.
In some embodiments, the second sending module 12 includes:
the first sub-sending module is configured to send second frame data to each slave if the master receives a reply frame of a first slave within a first preset time, where the first slave is one of the slaves.
The master computer needs to receive the reply frame of the first slave computer within the first preset time to send the second frame data to each slave computer.
In the present embodiment, the host 1 includes:
a fourth sending module, configured to send new first frame data to each slave if the master does not receive a reply frame from any of the slaves, where the new first frame data includes the master address and a new target slave address.
If the master does not receive the reply frame, the target slave address is not considered to be used by the slave, or more than two slaves use the target slave address, the second frame data is not sent again, the first frame data is sent again, the first frame data sent at the moment is called as new first frame data because the target slave address of the first frame data sent at the moment is different from that of the first frame data sent before, and the target slave address in the new first frame data is called as a new target slave address.
In some embodiments, in the present embodiment, the host 1 includes:
a fifth sending module, configured to send new first frame data to each slave if the master does not receive a reply frame from any of the slaves within a first preset time, where the new first frame data includes the master address and a new target slave address.
The master computer needs not to receive the reply frame of the first slave computer within the first preset time to send new first frame data to each slave computer.
In the present embodiment, the host 1 includes:
and the circulating module is used for sending new first frame data to each slave machine by the master machine until the slave machines finish address allocation or until the addresses in the address pool range finish polling, wherein the new first frame data comprises the master machine address and a new target slave machine address.
And completing address allocation by adopting each slave machine or completing polling by adopting the addresses in the address pool range, and finishing the circulation. When the slave machines are adopted to complete address allocation, after each slave machine receives the second frame data, a reply frame needs to be sent to the host machine, so that the host machine can count whether the slave machines complete address allocation.
The slave machine generates the address of the slave machine per se, and then the address of the slave machine per se is determined to be only used by the slave machine per se by receiving the first frame data and the second frame data sent by the host machine, so that the address of the slave machine is not required to be well allocated by the host machine and then sent to the slave machine, the address allocation efficiency is improved, and the problems that the host machine needs to occupy resources to process address allocation and the address allocation efficiency is low are solved.
As shown in fig. 4, the first slave 2 includes a first processing module 21, a third sending module 22, a second processing module 23, and an address determination module 24.
The first processing module 21 is configured to receive first frame data sent by a master to each slave, extract a target slave address from the first frame data, and determine whether the target slave address matches an own slave address, where the first frame data includes the master address and the target slave address, and the first slave is one of the slaves.
And each slave extracts a target slave address from the first frame data, acquires the own slave address, compares the target slave address with the own slave address, and judges whether the target slave address and the own slave address are consistent or not through comparison. The first slave is one of the slaves, and similarly, the first slave extracts the target slave address from the first frame data, acquires the own slave address, compares the target slave address with the own slave address, and judges whether the target slave address and the own slave address are consistent or not through comparison.
A third sending module 22, configured to, if a first slave determines that the target slave address matches a self-slave address, send a reply frame to the master according to the master address, where the first slave is one of the slaves.
If only one slave in the slaves determines that the target slave address is consistent with the own slave address, and the slave is the first slave, the first slave sends a reply frame to the master according to the master address, and the other slaves determine that the target slave address is inconsistent with the own slave address, and do not send the reply frame to the master.
The second processing module 23 is configured to receive second frame data sent by the master to each slave by the first slave, extract the target slave address from the second frame data, and determine whether the target slave address is consistent with the slave address of the first slave, where the second frame data includes the master address and the target slave address.
The master machine sends the second frame data to each slave machine after receiving the reply frame, each slave machine extracts the target slave machine address from the second frame data, then obtains the own slave machine address, compares the target slave machine address with the own slave machine address, and judges whether the target slave machine address and the own slave machine address are consistent through comparison.
An address determining module 24, configured to determine that the first slave is only in use by itself and complete address allocation if the first slave determines that the target slave address is consistent with the own slave address.
In this case, only the first slave determines that the target slave address matches the own slave address, and the other slaves determine that the target slave address does not match the own slave address, and the first slave receives the first frame data and the second frame data, and performs determination twice to determine that the own slave address is used only by itself, thereby completing address allocation.
In some embodiments, the address determination module 24 includes:
the first sub-judgment module is used for judging that the target slave address is consistent with the self slave address by the first slave;
the first sub-acquisition module is used for acquiring a time interval between the reception of first frame data and second frame data by the first slave;
the first sub-judgment module is used for judging whether the time interval is smaller than a preset time interval or not by the first slave;
and the first sub-determination module is used for determining that the address of the slave machine of the first slave machine is only used by the first slave machine if the address of the slave machine of the first slave machine is used by the first slave machine, so that the address allocation is completed.
And determining that the first frame data and the second frame data are transmitted by the host at the same determined address by judging the time interval.
In the present embodiment, the first slave 2 includes:
a sixth sending module, configured to, if a first slave determines that the target slave address matches a self-slave address, send an acknowledgement frame to the master according to the master address by the first slave, where there is more than one slave sending acknowledgement frame in each slave in addition to the first slave sending acknowledgement frame;
and the first generating module is used for the first slave machine not receiving the second frame data and randomly generating the slave machine address of the first slave machine again, wherein the first slave machine and more than one other slave machines simultaneously send reply frames to the master machine according to the master machine address to generate signal interference, and the master machine cannot receive the reply frames sent by the first slave machine and more than one other slave machines.
Two slaves of each extension judge that the target slave address is consistent with the slave address of the slave, of course, more than two slaves are also possible, the two slaves are respectively a first slave and a second slave, the first slave and the second slave both simultaneously send reply frames to the master according to the master address to generate signal interference, the master cannot receive the reply frames sent by the first slave and the second slave, and the master cannot send second frame data to the slaves. The re-randomly generated own slave address is also an address within the address pool.
In some embodiments, the first generating module comprises:
the first sub-generation module is configured to, after the first slave machine does not receive the second frame data, remove an address in an address determination table, and then randomly generate a slave machine address of the first slave machine again, where the address determination table is a target slave machine address of the second frame data received before the first slave machine records, and an address list is generated according to the target slave machine address.
After the address determination table exists in each slave, if the first slave does not receive the second frame data due to the fact that the first slave sends the reply frame, and the address of the first slave needs to be generated again, the address in the address determination table is removed, then the address of the first slave is generated again randomly, and the address of the second slave is also the address in the address pool range.
In the present embodiment, the first slave 2 includes:
the first judging module is used for judging whether the current power-on of the first slave computer is the first power-on;
and the fourth generation module is used for randomly generating the address of the slave machine of the first slave machine in the addresses in the address pool range if the first slave machine judges that the current power-on is the first power-on.
The first power-on refers to the first power-on after leaving the factory, that is, the own slave address is not generated, and the slave has no own slave address.
The slave machine generates the address of the slave machine per se, and then the address of the slave machine per se is determined to be only used by the slave machine per se by receiving the first frame data and the second frame data sent by the host machine, so that the address of the slave machine is not required to be well allocated by the host machine and then sent to the slave machine, the address allocation efficiency is improved, and the problems that the host machine needs to occupy resources to process address allocation and the address allocation efficiency is low are solved.
As shown in fig. 5, an embodiment of the present invention further provides a computer device, where the computer device may be a server, and an internal structure of the computer device may be as shown in fig. 5. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the computer designed processor is used to provide computational and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used for storing data such as a model of an automatic address allocation method. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement an automatic address assignment method.
An embodiment of the present invention also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements an automatic address assignment method,
it will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, databases, or other media provided herein or used in embodiments of the present invention may include non-volatile and/or volatile memory. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), double-rate SDRAM (SSRSDRAM), Enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and bus dynamic RAM (RDRAM).
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents and improvements made within the spirit and principle of the present invention are intended to be included within the scope of the present invention.

Claims (10)

1. A method for automatically assigning addresses, the method comprising:
the method comprises the steps that a master machine sends first frame data to each slave machine, wherein the first frame data comprise a master machine address and a target slave machine address, the master machine can receive a reply frame sent by one slave machine according to the master machine address due to the fact that the address of the slave machine per se is consistent with the address of the target slave machine, but cannot receive reply frames sent by more than two slave machines according to the master machine address due to the fact that the address of the slave machine per se is consistent with the address of the target slave machine;
if the master receives a reply frame of a first slave, the master sends second frame data to each slave, the second frame data comprises the master address and the target slave address, the second frame data is used for the first slave to determine that the slave address of the first slave is only used by the first slave, and address allocation is completed, wherein the first slave is one of the slaves.
2. The method of claim 1, wherein after the step of the master sending the first frame of data to the slaves, the method comprises:
and if the master does not receive the reply frame of any slave of the slaves, the master sends new first frame data to the slaves, wherein the new first frame data comprises the master address and a new target slave address.
3. The method as claimed in claim 1, wherein after the step of sending the second frame data to each slave if the master receives the reply frame from the first slave, the method comprises:
and the master machine sends new first frame data to each slave machine until each slave machine finishes address allocation or until the address in the address pool range finishes polling, wherein the new first frame data comprises the master machine address and a new target slave machine address.
4. A method for automatically assigning addresses, the method comprising:
the method comprises the steps that a first slave receives first frame data sent by a master to each slave, extracts a target slave address from the first frame data, and judges whether the target slave address is consistent with the slave address of the first slave, wherein the first frame data comprises the master address and the target slave address, and the first slave is one of the slaves;
if the first slave machine judges that the target slave machine address is consistent with the own slave machine address, the first slave machine sends a reply frame to the host machine according to the host machine address;
the first slave machine receives second frame data sent by the master machine to each slave machine, extracts the target slave machine address from the second frame data, and judges whether the target slave machine address is consistent with the slave machine address of the first slave machine, wherein the second frame data comprises the master machine address and the target slave machine address;
and if the first slave determines that the target slave address is consistent with the self slave address, the first slave determines that the self slave address is only used by the first slave, and the address allocation is finished.
5. The method according to claim 4, wherein the step of receiving first frame data transmitted from the master to each slave by the first slave, extracting a target slave address from the first frame data, and determining whether the target slave address matches the own slave address comprises:
if a first slave machine judges that the target slave machine address is consistent with the own slave machine address, the first slave machine sends a reply frame to the master machine according to the master machine address, wherein in addition to the first slave machine sending the reply frame, more than one slave machine sending the reply frame exist in each slave machine;
the first slave machine does not receive second frame data, and the first slave machine generates own slave machine addresses again randomly, wherein the first slave machine and more than one other slave machine simultaneously send reply frames to the master machine according to the master machine addresses to generate signal interference, and the master machine cannot receive the reply frames sent by the first slave machine and more than one other slave machine.
6. The method according to claim 5, wherein the step of the first slave device randomly generating its own slave address again without receiving the second frame data comprises:
the first slave machine does not receive second frame data, and after the address in an address determination table is removed, the first slave machine randomly generates a slave machine address again, wherein the address determination table is a target slave machine address of the second frame data received before the first slave machine records, and an address list is generated according to the target slave machine address.
7. The method according to claim 4, wherein before the step of receiving first frame data transmitted from the master to each slave by the first slave, extracting a target slave address from the first frame data, and determining whether the target slave address matches the own slave address, the method comprises:
the first slave machine judges whether the current power-on is the first power-on;
and if the first slave machine judges that the current power-on is the first power-on, the first slave machine randomly generates the address of the slave machine per se in the address within the address pool range.
8. An automatic address allocation device is characterized in that the device comprises a master machine or/and a first slave machine;
the host includes:
the first sending module is used for sending first frame data to each slave machine by the master machine, wherein the first frame data comprises a master machine address and a target slave machine address, the master machine can receive a reply frame sent by one slave machine according to the master machine address due to the fact that the own slave machine address is consistent with the target slave machine address, but cannot receive reply frames sent by more than two slave machines according to the master machine address due to the fact that the own slave machine address is consistent with the target slave machine address;
a second sending module, configured to send, by the master device, second frame data to each slave device if the master device receives a reply frame of a first slave device, where the second frame data includes the master address and the target slave address, and the second frame data is used by the first slave device to determine that its own slave address is only used by itself, so as to complete address allocation, where the first slave device is one of the slave devices;
the first slave machine includes:
the first processing module is used for receiving first frame data sent by a master to each slave by a first slave, extracting a target slave address from the first frame data, and judging whether the target slave address is consistent with the slave address of the first slave, wherein the first frame data comprises the master address and the target slave address, and the first slave is one of the slaves;
a third sending module, configured to send, if the first slave determines that the target slave address is consistent with the own slave address, the first slave sends a reply frame to the master according to the master address;
the second processing module is used for the first slave machine to receive second frame data sent by the host machine to each slave machine, extract the target slave machine address from the second frame data and judge whether the target slave machine address is consistent with the slave machine address of the first slave machine, wherein the second frame data comprises the host machine address and the target slave machine address;
and the address determining module is used for determining that the address of the slave machine is only used by the first slave machine if the first slave machine determines that the target slave machine address is consistent with the address of the slave machine, so that the address allocation is completed.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN202010270890.3A 2020-04-08 2020-04-08 Automatic address allocation method, automatic address allocation device, computer equipment and storage medium Active CN111597123B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010270890.3A CN111597123B (en) 2020-04-08 2020-04-08 Automatic address allocation method, automatic address allocation device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010270890.3A CN111597123B (en) 2020-04-08 2020-04-08 Automatic address allocation method, automatic address allocation device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111597123A true CN111597123A (en) 2020-08-28
CN111597123B CN111597123B (en) 2023-05-02

Family

ID=72192112

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010270890.3A Active CN111597123B (en) 2020-04-08 2020-04-08 Automatic address allocation method, automatic address allocation device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111597123B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112689028A (en) * 2020-12-15 2021-04-20 上海宏力达信息技术股份有限公司 Method for realizing automatic address allocation based on RS485
CN112929465A (en) * 2021-03-12 2021-06-08 珠海格力电器股份有限公司 Bus address allocation method and bus system
CN115208856A (en) * 2022-07-13 2022-10-18 珠海格力电器股份有限公司 Communication address allocation method, allocation device, processor and communication system
CN115604233A (en) * 2022-12-12 2023-01-13 河北振创电子科技有限公司(Cn) Method and device for actively registering address of modbus protocol equipment

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1495631A (en) * 2002-09-17 2004-05-12 ���ǵ�����ʽ���� Internetwork protocol address distribution equipment and method
CN102143411A (en) * 2010-07-14 2011-08-03 华为技术有限公司 Signal processing method, device and system
CN104410557A (en) * 2014-12-25 2015-03-11 深圳中科讯联科技有限公司 Dynamic networking method and communication method based on RS-485
CN105389278A (en) * 2015-10-13 2016-03-09 广东聚光电子科技有限公司 CAN bus based serial communication method for master and slave machines
CN105847456A (en) * 2015-01-13 2016-08-10 浙江大华技术股份有限公司 RS485 automatic address distribution method, device and system
CN105975345A (en) * 2016-05-20 2016-09-28 江苏得得空间信息科技有限公司 Video frame data dynamic equilibrium memory management method based on distributed memory
CN110401732A (en) * 2019-07-29 2019-11-01 江西科然科技有限公司 Battery management system slave addresses distribution method, system, mobile terminal and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1495631A (en) * 2002-09-17 2004-05-12 ���ǵ�����ʽ���� Internetwork protocol address distribution equipment and method
CN102143411A (en) * 2010-07-14 2011-08-03 华为技术有限公司 Signal processing method, device and system
CN104410557A (en) * 2014-12-25 2015-03-11 深圳中科讯联科技有限公司 Dynamic networking method and communication method based on RS-485
CN105847456A (en) * 2015-01-13 2016-08-10 浙江大华技术股份有限公司 RS485 automatic address distribution method, device and system
CN105389278A (en) * 2015-10-13 2016-03-09 广东聚光电子科技有限公司 CAN bus based serial communication method for master and slave machines
CN105975345A (en) * 2016-05-20 2016-09-28 江苏得得空间信息科技有限公司 Video frame data dynamic equilibrium memory management method based on distributed memory
CN110401732A (en) * 2019-07-29 2019-11-01 江西科然科技有限公司 Battery management system slave addresses distribution method, system, mobile terminal and storage medium

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112689028A (en) * 2020-12-15 2021-04-20 上海宏力达信息技术股份有限公司 Method for realizing automatic address allocation based on RS485
CN112689028B (en) * 2020-12-15 2023-03-24 上海宏力达信息技术股份有限公司 Method for realizing automatic address allocation based on RS485
CN112929465A (en) * 2021-03-12 2021-06-08 珠海格力电器股份有限公司 Bus address allocation method and bus system
CN115208856A (en) * 2022-07-13 2022-10-18 珠海格力电器股份有限公司 Communication address allocation method, allocation device, processor and communication system
CN115604233A (en) * 2022-12-12 2023-01-13 河北振创电子科技有限公司(Cn) Method and device for actively registering address of modbus protocol equipment

Also Published As

Publication number Publication date
CN111597123B (en) 2023-05-02

Similar Documents

Publication Publication Date Title
CN111597123A (en) Automatic address allocation method, device, computer equipment and storage medium
US10204072B2 (en) Method for automatically allocating addresses to similar bus users
CN111352873B (en) NVMe protocol command processing method and device
CN104113435A (en) Method and device for generating identifier
CN111600972A (en) Configuration method of double-stack address, server and readable storage medium
CN115442333A (en) Self-networking method and device based on RS485 communication, computer equipment and medium
US20240107647A1 (en) Control method, control device and lighting system
CN110888892B (en) Block synchronization method, device and storage medium
CN113242170A (en) Address allocation method and device
CN111741143A (en) Method and device for on-line distribution of Modbus addresses of electrical measuring instrument
CN116016140A (en) Communication exception handling method, master node, indoor distribution system and storage medium
EP3068112B1 (en) System and method for mac address acquisition
CN116126353A (en) Acceleration card software stack deployment method, device, equipment and storage medium
CN113504879A (en) Data storage method and intelligent household appliance
CN112835598B (en) Automobile ECU (electronic control Unit) refreshing method and system and computer readable storage medium thereof
JP4236650B2 (en) Network system
CN110138890B (en) Method, device, computer equipment and storage medium for acquiring IP address
CN106412657B (en) A kind of method and system of set-top box programming sequence code
CN113362196B (en) Low-delay addressing method for pre-dispatching service of power grid monitoring system
CN111698342A (en) Temperature controller communication address allocation method and system
CN113949628B (en) Automatic equipment adding method and system
CN114244804B (en) Network device starting method, equipment and storage medium based on dual systems
CN113259502B (en) Method, device and processor for power line carrier automatic addressing and computer readable storage medium thereof
CN109462499B (en) Initialization method and device of multi-network-port server and computer equipment
WO2021259108A1 (en) Resource allocation method and apparatus, server, and storage medium

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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: No. 1 by villagers' group of helongsha, Shengli village, Lishui Town, Nanhai District, Foshan City, Guangdong Province

Applicant after: Guangdong Kaili HVAC Co.,Ltd.

Address before: No. 1 by villagers' group of helongsha, Shengli village, Lishui Town, Nanhai District, Foshan City, Guangdong Province

Applicant before: GUANGDONG CHIGO HEATING AND VENTILATION EQUIPMENT Co.,Ltd.

GR01 Patent grant
GR01 Patent grant