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

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

Info

Publication number
CN111597123B
CN111597123B CN202010270890.3A CN202010270890A CN111597123B CN 111597123 B CN111597123 B CN 111597123B CN 202010270890 A CN202010270890 A CN 202010270890A CN 111597123 B CN111597123 B CN 111597123B
Authority
CN
China
Prior art keywords
slave
address
machine
host
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.)
Active
Application number
CN202010270890.3A
Other languages
Chinese (zh)
Other versions
CN111597123A (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 Kaili Hvac Co ltd
Original Assignee
Guangdong Kaili Hvac 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 Kaili Hvac Co ltd filed Critical Guangdong Kaili Hvac 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, a device, computer equipment and a storage medium for automatically distributing addresses. The method comprises the following steps: the host computer sends first frame data to each slave computer; if the host receives a reply frame of a first slave, wherein the first slave is one slave in all slaves, the host sends second frame data to all slaves, the second frame data comprises the host address and the target slave address, and the second frame data is used for the first slave to determine that the own slave address is only used by the first slave, so that address allocation is completed. The slave machine generates the address of the slave machine by itself, and then the first frame data and the second frame data sent by the host machine are received to determine that the address of the slave machine is only used by itself, so that the address allocation is completed, the host machine is not required to send the address allocation of the slave machine to the slave machine again, the efficiency of the address allocation is improved, and the problems that the host machine needs to occupy resources to process the address allocation and the address allocation efficiency is low are solved.

Description

Automatic address allocation method, automatic address allocation device, computer equipment and storage medium
Technical Field
The invention relates to the technical field of RS485 communication, in particular to a method, a device, computer equipment and a storage medium for automatically distributing addresses.
Background
The RS485 communication system transmits a corresponding address allocation instruction to the host in a specific time, and the slave receives the address allocation instruction and then completes address allocation through a series of communication actions of the master and the slave. The host distributes the addresses of the slaves well and then sends the addresses to the slaves, and the slaves are configured according to the received addresses, so that the host needs to occupy resources to process the address distribution, and the address distribution efficiency is low.
Disclosure of Invention
Aiming at the defects of the prior art, the invention provides an automatic address allocation method, an automatic address allocation device, computer equipment and a storage medium, and aims to solve 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 host sends first frame data to each slave, wherein the first frame data comprises a host address and a target slave address, the host can receive a reply frame sent by one slave according to the host address because the slave address of the host is consistent with the target slave address, but can not receive reply frames sent by more than two slaves according to the host address because the slave address of the host is consistent with the target slave address;
if the host receives the reply frame of the first slave, the host sends second frame data to each slave, wherein the second frame data comprises the host address and the target slave address, the second frame data is used for the first slave to determine that the own slave address is only used by the first slave, and address allocation is completed, and the first slave is one slave in each slave.
Further, after the step of the master sending the first frame data to each slave, the method includes:
if the host does not receive the reply frame of any slave of each slave, the host sends new first frame data to each slave, wherein the new first frame data comprises the host address and a new target slave address.
Further, after the step of sending the second frame data to each slave by the master if the master receives the reply frame of the first slave, the method includes:
and the host sends new first frame data to each slave until each slave completes address allocation or until addresses in the address pool range complete polling, wherein the new first frame data comprises the host address and a new target slave address.
The invention also provides a method for automatically distributing addresses, which comprises the following steps:
the method comprises the steps that a first slave receives first frame data sent by a host to each slave, extracts a target slave address from the first frame data, and judges whether the target slave address is consistent with a slave address of the first slave, wherein the first frame data comprises the host address and the target slave address, and the first slave is one slave in each slave;
if the first slave determines that the target slave address is consistent with the self slave address, the first slave sends a reply frame to the host according to the host address;
the first slave receives second frame data sent by the host to each slave, extracts the target slave address from the second frame data, judges whether the target slave address is consistent with the own slave address or not, and the second frame data comprises the host address and the target slave 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 itself, and the address allocation is completed.
Further, after the step of receiving, by the first slave, first frame data sent by the master to each slave, extracting a target slave address from the first frame data, and determining whether the target slave address is consistent with the own slave address, the method includes:
if the first slave determines that the target slave address is consistent with the slave address of the first slave, the first slave sends a reply frame to the host according to the host address, wherein each slave sends the reply frame in addition to the first slave, and more than one slave sends the reply frame;
the first slave machine does not receive the second frame data, and the first slave machine generates the address of the slave machine again and randomly, wherein the first slave machine and the other slave machines can not receive the reply frames sent by the first slave machine and the other slave machines because the first slave machine and the other slave machines send the reply frames to the host machine according to the host machine address at the same time to generate signal interference.
Further, in the step that the first slave does not receive the second frame data, the first slave randomly generates the address of the slave, the method includes:
and after the first slave machine does not receive the second frame data, the first slave machine eliminates the address in the address determination table, and then randomly generates the address of the slave machine, 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, by the first slave, first frame data sent by the master to each slave, extracting a target slave address from the first frame data, and determining whether the target slave address is consistent with the own slave address, the method includes:
the first slave machine judges whether the current power-on is the first power-on or not;
and if the first slave determines that the current power-on is the first power-on, the first slave randomly generates the address of the slave in the address pool range.
The invention also provides an automatic address allocation device, which 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 a host machine, wherein the first frame data comprises a host machine address and a target slave machine address, the host machine can receive a reply frame sent by one slave machine according to the host machine address because the slave machine address of the host machine is consistent with the target slave machine address, but can not receive reply frames sent by more than two slave machines according to the host machine address because the slave machine address of the host machine is consistent with the target slave machine address;
the second sending module is used for sending second frame data to each slave machine if the host machine receives a reply frame of the first slave machine, wherein the second frame data comprises the host 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 is only used by the first slave machine and complete address allocation, and the first slave machine is one slave machine in each slave machine;
the first slave comprises:
the first processing module is used for receiving first frame data sent by a host to each slave from a first slave, extracting a target slave address from the first frame data, and judging whether the target slave address is consistent with the own slave address or not, wherein the first frame data comprises the host address and the target slave address, and the first slave is one slave in each slave;
the third sending module is used for sending a reply frame to the host according to the host address by the first slave if the first slave judges that the target slave address is consistent with the own slave address;
the second processing module is used for receiving second frame data sent by the host to each slave by the first slave, extracting the target slave address from the second frame data, judging whether the target slave address is consistent with the own slave address or not, and the second frame data comprises the host address and the target slave address;
and the address determining module is used for determining that the self slave address is only used by the first slave to complete address allocation if the first slave determines that the target slave address is consistent with the self slave address.
The invention also provides a computer device comprising a memory storing a computer program and a processor implementing the steps of any of the methods described above when the processor executes the computer program.
The invention also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of the method of any of the preceding claims.
According to the technical scheme, the invention has the beneficial effects that: the slave machine generates the address of the slave machine by itself, and then the first frame data and the second frame data sent by the host machine are received to determine that the address of the slave machine is only used by itself, so that the address allocation is completed, the host machine is not required to send the address allocation of the slave machine to the slave machine again, the efficiency of the address allocation is improved, and the problems that the host machine needs to occupy resources to process the address allocation and the address allocation efficiency is low are solved.
Drawings
FIG. 1 is a flow chart of a method for automatically assigning addresses provided by an embodiment of the present invention;
FIG. 2 is a flow chart of a method for automatically assigning addresses provided by another embodiment of the present invention;
FIG. 3 is a functional block diagram of an automatic address allocation apparatus according to an embodiment of the present invention;
FIG. 4 is a functional block diagram of an automatic address allocation apparatus according to another embodiment of the present invention;
fig. 5 is a schematic block diagram of a computer device to which an embodiment of the present invention is applied.
Detailed Description
The present invention will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present invention more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
As shown in fig. 1, an embodiment of the present invention proposes a method for automatically allocating addresses, the method including the following steps:
in step S101, the host sends first frame data to each slave, where the first frame data includes a host address and a target slave address, and the host can receive a reply frame sent by one slave according to the host address because its own slave address is consistent with the target slave address, but cannot receive a reply frame sent by more than two slaves according to the host address because its own slave address is consistent with the target slave address.
The first frame data may include a frame header, a frame trailer, and a check code in addition to the master address and the target slave address. The frame header and the frame trailer may identify whether the first frame data is a complete frame 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 transmitted for the first time is the first one of the addresses in the address pool range in order, and the target slave address in the first frame data transmitted for the second time is the second one of the addresses in the address pool range in order.
In this embodiment, the host can receive a reply frame transmitted from one slave according to the host address because the own slave address coincides with the target slave address, but cannot receive a reply frame transmitted from two or more slaves according to the host address because the own slave address coincides with the target slave address. Since two or more slaves simultaneously transmit a reply frame to the master according to the address of the master, signal interference is generated, and the master cannot receive the reply frame transmitted from the slaves.
Step S102, if the host receives the reply frame of the first slave, the host sends second frame data to each slave, where the second frame data includes the host address and the target slave address, and the second frame data is used by the first slave to determine that the own slave address is only used by itself, and complete address allocation, and the first slave is one slave among the slaves.
The host computer will send the second frame data after receiving the reply frame, the second frame data can be the same as first frame data, can also be different from first frame data, the second frame data includes host computer address and goal slave address at least, the first slave computer receives the second frame data again after receiving the first frame data, then the first slave computer can fix the own slave computer address only oneself use, will not duplicate the address with other slave computers, do not need to change the address, finish the address allocation.
In some embodiments, in step S102, comprising:
and if the host receives the reply frame of the first slave machine within the first preset time, wherein the first slave machine is one slave machine in all slave machines, the host sends second frame data to all slave machines.
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, it includes:
if the host does not receive the reply frame of any slave of each slave, the host sends new first frame data to each slave, wherein the new first frame data comprises the host address and a new target slave address.
If the host does not receive the reply frame, the target slave address is not used by the slave, or more than two slaves use the target slave address, the second frame data is not transmitted, and the first frame data is transmitted again, and the first frame data transmitted at this time is called as new first frame data because the target slave address of the first frame data transmitted at this time is different from the target slave address of the first frame data transmitted before, and the target slave address in the new first frame data is called as new target slave address.
In some embodiments, in the present embodiment, after step S102, it includes:
if the host does not receive the reply frame of any slave of each slave within the first preset time, the host sends new first frame data to each slave, wherein the new first frame data comprises the host address and a new target slave address.
The host computer needs to send new first frame data to each slave computer only if no reply frame of the first slave computer is received within a first preset time.
In the present embodiment, after step S102, it includes:
and the host sends new first frame data to each slave until each slave completes address allocation or until addresses in the address pool range complete polling, wherein the new first frame data comprises the host address and a new target slave address.
And (5) finishing address allocation by adopting each slave machine or finishing polling by adopting addresses in the address pool range, and ending the cycle. When the address assignment is completed by using each slave, each slave needs to send a reply frame to the master after receiving the second frame data, so that the master counts whether each slave has completed the address assignment.
The slave machine generates the address of the slave machine by itself, and then the first frame data and the second frame data sent by the host machine are received to determine that the address of the slave machine is only used by itself, so that the address allocation is completed, the host machine is not required to send the address allocation of the slave machine to the slave machine again, the efficiency of the address allocation is improved, and the problems that the host machine needs to occupy resources to process the address allocation and the address allocation efficiency is low are solved.
As shown in fig. 2, an embodiment of the present invention proposes a method for automatically allocating addresses, where the method includes:
step 201, a first slave receives first frame data sent by a host to each slave, extracts a target slave address from the first frame data, and judges whether the target slave address is consistent with the own slave address, wherein the first frame data comprises a host address and a target slave address, and the first slave is one slave in each slave.
Each slave machine extracts a target slave machine address from the first frame data, acquires 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. The first slave is one slave among 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 is consistent with the slave address, the first slave sends a reply frame to the host according to the host address, and the first slave is one slave in all slaves.
If only one slave machine in each slave machine judges that the target slave machine address is consistent with the slave machine address of the slave machine, the slave machine is a first slave machine, the first slave machine sends a reply frame to the host machine according to the host machine address, and other slave machines judge that the target slave machine address is inconsistent with the slave machine address of the slave machine, and the reply frame is not sent to the host machine.
Step S203, the first slave receives second frame data sent by the host to each slave, extracts the target slave address from the second frame data, and determines whether the target slave address is consistent with the own slave address, where the second frame data includes the host address and the target slave address.
After receiving the reply frame, the host sends second frame data to each slave, each slave extracts the target slave address from the second 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 S204, if the first slave determines that the target slave address is consistent with the own slave address, the first slave determines that the own slave address is only used by itself, and the address allocation is completed.
At this time, only the first slave determines that the target slave address is identical to the own slave address, and the other slaves determine that the target slave address is not identical to the own slave address, and the first slave receives the first frame data and the second frame data, performs two determinations, determines that the own slave address is only used by itself, and completes the address allocation.
In some embodiments, in step S204, comprising:
the first slave determines that the target slave address is consistent with the own slave address;
the first slave acquires a time interval between receiving 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 yes, the first slave determines that the slave address is only used by the first slave, and 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, after step S201, it includes:
if the first slave determines that the target slave address is consistent with the slave address of the first slave, the first slave sends a reply frame to the host according to the host address, wherein each slave sends the reply frame in addition to the first slave, and more than one slave sends the reply frame;
the first slave machine does not receive the second frame data, and the first slave machine generates the address of the slave machine again and randomly, wherein the first slave machine and the other slave machines can not receive the reply frames sent by the first slave machine and the other slave machines because the first slave machine and the other slave machines send the reply frames to the host machine according to the host machine address at the same time to generate signal interference.
It is also possible that each slave has two slaves for determining that the target slave address is identical to the own slave address, of course, two or more slaves are respectively a first slave and a second slave, each of which transmits a reply frame to the master at the same time according to the master address, and since each of the first slave and the second slave transmits a reply frame to the master at the same time according to the master address, signal interference is generated, the master cannot receive the reply frame transmitted by the first slave and the second slave, and the master cannot transmit the second frame data to each slave, and therefore, neither the first slave nor the second slave receives the second frame data, and the first slave and the second slave consider that the own slave address is duplicated, trigger a regeneration event, and each of the first slave and the second slave regenerates the own slave address at random. The re-random generation of the own slave addresses 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, the first slave randomly generates the slave address of the first slave, the method includes:
and after the first slave machine does not receive the second frame data, the first slave machine eliminates the address in the address determination table, and then randomly generates the address of the slave machine, 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 each slave has an address determination table, if the first slave does not receive the second frame data because of sending a reply frame, and the address of the slave needs to be regenerated, the address in the address determination table is removed, then the address of the slave is regenerated randomly, and the address of the slave is regenerated randomly and is also in the address pool range.
In the present embodiment, before step S201, it includes:
the first slave machine judges whether the current power-on is the first power-on or not;
and if the first slave determines that the current power-on is the first power-on, the first slave randomly generates the address of the slave in the address pool range.
The first power-up refers to the first power-up 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 by itself, and then the first frame data and the second frame data sent by the host machine are received to determine that the address of the slave machine is only used by itself, so that the address allocation is completed, the host machine is not required to send the address allocation of the slave machine to the slave machine again, the efficiency of the address allocation is improved, and the problems that the host machine needs to occupy resources to process the address allocation and the address allocation efficiency is low are solved.
As shown in fig. 3, an embodiment of the present invention provides an automatic address allocation device, which includes a master 1 and/or a first slave 2.
The host 1 comprises 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 host address and a target slave address, and the host can receive a reply frame sent by one slave according to the host address because its own slave address is consistent with the target slave address, but cannot receive a reply frame sent by more than two slaves according to the host address because its own slave address is consistent with the target slave address.
The first frame data may include a frame header, a frame trailer, and a check code in addition to the master address and the target slave address. The frame header and the frame trailer may identify whether the first frame data is a complete frame 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 transmitted for the first time is the first one of the addresses in the address pool range in order, and the target slave address in the first frame data transmitted for the second time is the second one of the addresses in the address pool range in order.
In this embodiment, the host can receive a reply frame transmitted from one slave according to the host address because the own slave address coincides with the target slave address, but cannot receive a reply frame transmitted from two or more slaves according to the host address because the own slave address coincides with the target slave address. Since two or more slaves simultaneously transmit a reply frame to the master according to the address of the master, signal interference is generated, and the master cannot receive the reply frame transmitted from the slaves.
And a second sending module 12, configured to send, if the host receives the reply frame of the first slave, second frame data to each slave, where the second frame data includes the host address and the target slave address, and the second frame data is used by the first slave to determine that the own slave address is only used by itself, and complete address allocation, and the first slave is one slave among the slaves.
The host computer will send the second frame data after receiving the reply frame, the second frame data can be the same as first frame data, can also be different from first frame data, the second frame data includes host computer address and goal slave address at least, the first slave computer receives the second frame data again after receiving the first frame data, then the first slave computer can fix the own slave computer address only oneself use, will not duplicate the address with other slave computers, do not need to change the address, finish the address allocation.
In some embodiments, the second transmitting module 12 includes:
and the first sub-sending module is used for sending second frame data to each slave machine if the host machine receives the reply frame of the first slave machine within the first preset time, wherein the first slave machine is one slave machine in each slave machine.
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:
and the fourth sending module is used for sending new first frame data to each slave machine if the host machine does not receive the reply frame of any slave machine of each slave machine, wherein the new first frame data comprises the host machine address and a new target slave machine address.
If the host does not receive the reply frame, the target slave address is not used by the slave, or more than two slaves use the target slave address, the second frame data is not transmitted, and the first frame data is transmitted again, and the first frame data transmitted at this time is called as new first frame data because the target slave address of the first frame data transmitted at this time is different from the target slave address of the first frame data transmitted before, and the target slave address in the new first frame data is called as new target slave address.
In some embodiments, in the present embodiment, the host side 1 includes:
and a fifth sending module, configured to send new first frame data to each slave machine if the host machine does not receive a reply frame of any slave machine of each slave machine within a first preset time, where the new first frame data includes the host machine address and a new target slave machine address.
The host computer needs to send new first frame data to each slave computer only if no reply frame of the first slave computer is received within a first preset time.
In the present embodiment, the host 1 includes:
and the circulation module is used for sending new first frame data to each slave machine until each slave machine completes address allocation or until the addresses in the address pool range complete polling, and the new first frame data comprises the host machine address and a new target slave machine address.
And (5) finishing address allocation by adopting each slave machine or finishing polling by adopting addresses in the address pool range, and ending the cycle. When the address assignment is completed by using each slave, each slave needs to send a reply frame to the master after receiving the second frame data, so that the master counts whether each slave has completed the address assignment.
The slave machine generates the address of the slave machine by itself, and then the first frame data and the second frame data sent by the host machine are received to determine that the address of the slave machine is only used by itself, so that the address allocation is completed, the host machine is not required to send the address allocation of the slave machine to the slave machine again, the efficiency of the address allocation is improved, and the problems that the host machine needs to occupy resources to process the 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 transmitting module 22, a second processing module 23, and an address determining module 24.
The first processing module 21 is configured to receive, by a first slave, first frame data sent by a master to each slave, where the first frame data includes a master address and a target slave address, extract a target slave address from the first frame data, and determine whether the target slave address is consistent with a slave address of the first slave, and the first slave is one of the slaves.
Each slave machine extracts a target slave machine address from the first frame data, acquires 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. The first slave is one slave among 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.
And a third sending module 22, configured to send a reply frame to the host according to the host address if the first slave determines that the target slave address is consistent with the own slave address, where the first slave is one slave among the slaves.
If only one slave machine in each slave machine judges that the target slave machine address is consistent with the slave machine address of the slave machine, the slave machine is a first slave machine, the first slave machine sends a reply frame to the host machine according to the host machine address, and other slave machines judge that the target slave machine address is inconsistent with the slave machine address of the slave machine, and the reply frame is not sent to the host machine.
And the second processing module 23 is configured to receive, by the first slave, second frame data sent by the host to each slave, extract the target slave address from the second frame data, and determine whether the target slave address is consistent with the own slave address, where the second frame data includes the host address and the target slave address.
After receiving the reply frame, the host sends second frame data to each slave, each slave extracts the target slave address from the second 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.
And the address determining module 24 is configured to determine that the own slave address is only used by the first slave if the first slave determines that the target slave address is consistent with the own slave address, and complete address allocation.
At this time, only the first slave determines that the target slave address is identical to the own slave address, and the other slaves determine that the target slave address is not identical to the own slave address, and the first slave receives the first frame data and the second frame data, performs two determinations, determines that the own slave address is only used by itself, and completes the address allocation.
In some embodiments, address determination module 24 includes:
the first sub-judging module is used for judging that the target slave machine address is consistent with the own slave machine address by the first slave machine;
the first sub-acquisition module is used for acquiring a time interval between receiving first frame data and second frame data by the first slave;
the first sub-judging 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 own slave address is only used by the first slave if the first slave is yes, and finishing 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, the first slave 2 includes:
a sixth sending module, configured to send a reply frame to the host according to the host address if the first slave determines that the target slave address is consistent with the own slave address, where each slave sends a reply frame in addition to the first slave, and there is more than one slave sending a reply frame;
the first generating module is configured to, when the first slave does not receive the second frame data, generate the own slave address at random again by the first slave, where the first slave and the more than one slave simultaneously send a reply frame to the host according to the host address, and generate signal interference, and the host cannot receive the reply frame sent by the first slave and the more than one slave.
It is also possible that each slave has two slaves for determining that the target slave address is identical to the own slave address, of course, two or more slaves are respectively a first slave and a second slave, each of which transmits a reply frame to the master at the same time according to the master address, and since each of the first slave and the second slave transmits a reply frame to the master at the same time according to the master address, signal interference is generated, the master cannot receive the reply frame transmitted by the first slave and the second slave, and the master cannot transmit the second frame data to each slave, and therefore, neither the first slave nor the second slave receives the second frame data, and the first slave and the second slave consider that the own slave address is duplicated, trigger a regeneration event, and each of the first slave and the second slave regenerates the own slave address at random. The re-random generation of the own slave addresses is also an address within the address pool.
In some embodiments, the first generation module comprises:
the first sub-generation module is used for the first slave machine not receiving the second frame data, and the first slave machine eliminates the address in the address determination table and then regenerates the address of the slave machine, wherein the address determination table is the target slave machine address of the second frame data received before the first slave machine records, and the address list is generated according to the target slave machine address.
After each slave has an address determination table, if the first slave does not receive the second frame data because of sending a reply frame, and the address of the slave needs to be regenerated, the address in the address determination table is removed, then the address of the slave is regenerated randomly, and the address of the slave is regenerated randomly and is also 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 is the first power-on or not by the first slave;
and the fourth generation module is used for randomly generating the address of the slave machine from the addresses in the address pool range of the first slave machine if the first slave machine judges that the current power-on is the first power-on.
The first power-up refers to the first power-up 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 by itself, and then the first frame data and the second frame data sent by the host machine are received to determine that the address of the slave machine is only used by itself, so that the address allocation is completed, the host machine is not required to send the address allocation of the slave machine to the slave machine again, the efficiency of the address allocation is improved, and the problems that the host machine needs to occupy resources to process the address allocation and the address allocation efficiency is low are solved.
As shown in fig. 5, in an embodiment of the present invention, a computer device is further provided, where the computer device may be a server, and the 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 is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is used for storing data such as models of the 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 a method of automatically assigning addresses.
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 a method of automatically assigning addresses,
those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium provided by the present invention and used in embodiments may include non-volatile and/or volatile memory. The nonvolatile 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), dual speed data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
The foregoing description of the preferred embodiment of the invention is not intended to be limiting, but rather is intended to cover all modifications, equivalents, and alternatives falling within the spirit and principles of the invention.

Claims (6)

1. A method of automatically assigning addresses, the method comprising:
the method comprises the steps that a first slave receives first frame data sent by a host to each slave, extracts a target slave address from the first frame data, and judges whether the target slave address is consistent with a slave address of the first slave, wherein the first frame data comprises the host address and the target slave address, and the first slave is one slave in each slave;
if the first slave determines that the target slave address is consistent with the self slave address, the first slave sends a reply frame to the host according to the host address;
the first slave receives second frame data sent by the host to each slave, extracts the target slave address from the second frame data, judges whether the target slave address is consistent with the own slave address or not, and the second frame data comprises the host address and the target slave address;
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 itself, and the address allocation is completed;
after the first slave receives the first frame data sent by the master to each slave, extracting a target slave address from the first frame data, and judging whether the target slave address is consistent with the own slave address, the method comprises the following steps:
if the first slave determines that the target slave address is consistent with the slave address of the first slave, the first slave sends a reply frame to the host according to the host address, wherein each slave sends the reply frame in addition to the first slave, and more than one slave sends the reply frame;
the first slave machine does not receive the second frame data, and the first slave machine generates the address of the slave machine again and randomly, wherein the first slave machine and the other slave machines can not receive the reply frames sent by the first slave machine and the other slave machines because the first slave machine and the other slave machines send the reply frames to the host machine according to the host machine address at the same time to generate signal interference.
2. The method of automatically assigning addresses according to claim 1, wherein in the step of the first slave device re-randomly generating its own slave device address without receiving the second frame data, the method comprises:
and after the first slave machine does not receive the second frame data, the first slave machine eliminates the address in the address determination table, and then randomly generates the address of the slave machine, 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.
3. The method of automatically assigning addresses according to claim 1, wherein before the step of the first slave receiving first frame data sent from the master to each slave, extracting a target slave address from the first frame data, and judging whether the target slave address coincides with the own slave address, comprising:
the first slave machine judges whether the current power-on is the first power-on or not;
and if the first slave determines that the current power-on is the first power-on, the first slave randomly generates the address of the slave in the address pool range.
4. An automatic address allocation device, characterized in that the device comprises a master machine and a first slave machine;
the host includes:
the first sending module is used for sending first frame data to each slave machine by a host machine, wherein the first frame data comprises a host machine address and a target slave machine address, the host machine can receive a reply frame sent by one slave machine according to the host machine address because the slave machine address of the host machine is consistent with the target slave machine address, but can not receive reply frames sent by more than two slave machines according to the host machine address because the slave machine address of the host machine is consistent with the target slave machine address;
the second sending module is used for sending second frame data to each slave machine if the host machine receives a reply frame of the first slave machine, wherein the second frame data comprises the host 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 is only used by the first slave machine and complete address allocation, and the first slave machine is one slave machine in each slave machine;
the first slave comprises:
the first processing module is used for receiving first frame data sent by a host to each slave from a first slave, extracting a target slave address from the first frame data, and judging whether the target slave address is consistent with the own slave address or not, wherein the first frame data comprises the host address and the target slave address, and the first slave is one slave in each slave;
the third sending module is used for sending a reply frame to the host according to the host address by the first slave if the first slave judges that the target slave address is consistent with the own slave address;
the second processing module is used for receiving second frame data sent by the host to each slave by the first slave, extracting the target slave address from the second frame data, judging whether the target slave address is consistent with the own slave address or not, and the second frame data comprises the host address and the target slave address;
the address determining module is used for determining that the self slave address is only used by the first slave to complete address allocation if the first slave determines that the target slave address is consistent with the self slave address;
a sixth sending module, configured to send a reply frame to the host according to the host address if the first slave determines that the target slave address is consistent with the own slave address, where each slave sends a reply frame in addition to the first slave, and there is more than one slave sending a reply frame;
the first generating module is configured to, when the first slave does not receive the second frame data, generate the own slave address at random again by the first slave, where the first slave and the more than one slave simultaneously send a reply frame to the host according to the host address, and generate signal interference, and the host cannot receive the reply frame sent by the first slave and the more than one slave.
5. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any one of claims 1 to 3 when the computer program is executed.
6. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 3.
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 CN111597123A (en) 2020-08-28
CN111597123B true 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)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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

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

Also Published As

Publication number Publication date
CN111597123A (en) 2020-08-28

Similar Documents

Publication Publication Date Title
CN111597123B (en) Automatic address allocation method, automatic address allocation device, computer equipment and storage medium
CN107995215B (en) Control method and device of intelligent household equipment and cloud platform server
CN110995513B (en) Data sending and receiving method in Internet of things system, internet of things equipment and platform
CN103119916A (en) Method for automatically assigning addresses to identical bus users
CN103856569A (en) Method and device for synchronizing domain name system resource information
CN110297608B (en) Data processing method, device and storage medium
CN115314470A (en) RS-485 networking communication address automatic allocation method, host, slave and system
CN111352873B (en) NVMe protocol command processing method and device
CN111540190A (en) Data distribution method and device based on double-core intelligent electric meter and computer equipment
CN104113435A (en) Method and device for generating identifier
CN111651526B (en) Data synchronization method of redundant front-end processor, front-end processor and processing system
CN114401250A (en) Address allocation method and device
CN113326104B (en) Method, system and device for modifying internal configuration of virtual machine
CN110708400A (en) Network address allocation method, device, node equipment and storage medium
CN112835598B (en) Automobile ECU (electronic control Unit) refreshing method and system and computer readable storage medium thereof
CN107203915B (en) Data storage method and device
CN113448304B (en) Vehicle ECU diagnostic method and system
CN113504879A (en) Data storage method and intelligent household appliance
CN111698342A (en) Temperature controller communication address allocation method and system
CN107678866B (en) Partition communication method and device based on embedded operating system
CN113032307A (en) Integrated device access request processing method and related assembly
CN114116544A (en) Method, device and equipment for acquiring slot information and storage medium
CN113949689B (en) Multi-module lower computer address automatic allocation method and device and multi-module air conditioning system
CN113259502B (en) Method, device and processor for power line carrier automatic addressing and computer readable storage medium thereof
CN113949628B (en) Automatic equipment adding method and system

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