CN115987947A - Method and apparatus for allocating addresses for hosts - Google Patents

Method and apparatus for allocating addresses for hosts Download PDF

Info

Publication number
CN115987947A
CN115987947A CN202211548422.3A CN202211548422A CN115987947A CN 115987947 A CN115987947 A CN 115987947A CN 202211548422 A CN202211548422 A CN 202211548422A CN 115987947 A CN115987947 A CN 115987947A
Authority
CN
China
Prior art keywords
random number
address
slave
command
value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211548422.3A
Other languages
Chinese (zh)
Inventor
邓剑辉
刘棋星
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou On Bright Electronics Co Ltd
Original Assignee
Guangzhou On Bright Electronics 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 Guangzhou On Bright Electronics Co Ltd filed Critical Guangzhou On Bright Electronics Co Ltd
Priority to CN202211548422.3A priority Critical patent/CN115987947A/en
Publication of CN115987947A publication Critical patent/CN115987947A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Small-Scale Networks (AREA)

Abstract

The invention provides a method and a device for allocating addresses for a host. The method for allocating the address for the host comprises the following steps: broadcasting a start allocation address command to cause at least one slave of all slaves associated with the master to enter an address allocation mode; broadcasting a random number generation command to cause the at least one slave to generate a random number; obtaining feedback information of the at least one slave machine in response to the generated random number to determine a target slave machine of the at least one slave machine; and assigning an address to the target slave. According to the method and the device for allocating the address for the master, the master can broadcast the relevant command to the slave so that the slave generates the random number, and the slave is automatically allocated with the address by using the random number, so that the efficiency of allocating the address is improved, and the cost of allocating the address is saved.

Description

Method and apparatus for allocating addresses for hosts
Technical Field
The present invention relates to the field of communications, and in particular, to a method and apparatus for allocating addresses for a host.
Background
In the field of communications such as the internet of things, there are cases where a large number of masters and associated slaves communicate by broadcast, for example, where the masters and slaves communicate using an RS485 bus. In this case, when allocating an address to a slave, it is usually necessary to manually allocate the address. However, in the case of a master with more associated slaves, this allocation scheme is very time consuming and very error prone.
Therefore, a more efficient and less costly way of address allocation is needed.
Disclosure of Invention
According to an aspect of exemplary embodiments of the present invention, there is provided a method of allocating an address for a host, including: broadcasting a start allocation address command to cause at least one slave of all slaves associated with the master to enter an address allocation mode; broadcasting a random number generation command to cause the at least one slave to generate a random number; obtaining feedback information of the at least one slave in response to the generated random number to determine a target slave of the at least one slave; and assigning an address to the target slave.
According to another aspect of exemplary embodiments of the present invention, there is provided an apparatus for allocating an address for a host, including: a first broadcasting unit configured to broadcast a start allocation address command to cause at least one slave among all slaves associated with a master to enter an address allocation mode; a second broadcasting unit configured to broadcast a random number generation command to cause the at least one slave to generate a random number; a determining unit configured to acquire feedback information of the at least one slave in response to the generation of the random number to determine a target slave among the at least one slave; and an address allocation unit configured to allocate an address to the target slave.
According to another aspect of exemplary embodiments of the present invention, there is provided a computer-readable medium storing instructions that, when executed by a processor, cause the processor to perform the above method of allocating an address for a host according to an embodiment of the present disclosure.
According to the method and the device for allocating the address of the host, the host broadcasts the relevant command to the slave so that the slave generates the random number, and the random number is used for automatically allocating the address to the slave, so that the efficiency of allocating the address is improved, and the cost of allocating the address is saved.
Drawings
The invention may be better understood from the following description of specific embodiments thereof taken in conjunction with the accompanying drawings, in which:
fig. 1 shows a flowchart of a method of allocating an address for a host according to an example embodiment of the present invention.
Fig. 2 shows a flowchart of a method of allocating an address for a host according to another exemplary embodiment of the present invention.
Fig. 3 shows a flowchart of a method of allocating an address for a host according to another exemplary embodiment of the present invention.
Fig. 4 shows a flowchart of a method of allocating an address for a host according to another exemplary embodiment of the present invention.
Fig. 5 shows a flowchart of a process in which a master assigns addresses to slaves, according to an example embodiment of the present invention.
Fig. 6 illustrates a block diagram of an apparatus for allocating an address of a host according to an exemplary embodiment of the present invention.
Detailed Description
Features and exemplary embodiments of various aspects of the present invention will be described in detail below. In the following detailed description, numerous specific details are set forth in order to provide a thorough understanding of the present invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced without some of these specific details. The following description of the embodiments is merely intended to provide a better understanding of the present invention by illustrating examples of the present invention. The present invention is in no way limited to any specific configuration and algorithm set forth below, but rather covers any modification, replacement or improvement of elements, components or algorithms without departing from the spirit of the invention. In the drawings and the following description, well-known structures and techniques are not shown in order to avoid unnecessarily obscuring the present invention.
Fig. 1 shows a flowchart of a method of allocating an address for a host according to an exemplary embodiment of the present invention.
In the embodiment of the invention, the master can be associated with each slave through the RS485 bus, and can also be associated with the slave through other modes to communicate with the slave in a broadcasting mode.
Referring to fig. 1, in step S110, a start allocation address command is broadcast to cause at least one slave among all slaves associated with a master to enter an address allocation mode.
In one embodiment, the start allocate address command may include: no address allocation command, a predetermined address allocation command, or a forced allocation command.
In one example, the no address allocation command may be used to cause all slaves that do not have an address to enter an address allocation mode, i.e., to allocate addresses for slaves that have not been allocated an address. The predetermined address allocation command may be used to cause a slave having a predetermined address among all slaves to enter an address allocation mode, i.e. to perform a re-address allocation for the slave to which the address has been allocated. The forced allocation command may be used to bring all slaves into an address allocation mode, i.e. for address allocation for all slaves.
In one example, after the slave machines receive the address allocation starting command broadcast by the master machine, each slave machine can enter the address allocation mode, and then each slave machine can judge whether the slave machine is the slave machine indicated by the address allocation starting command, if so, the slave machine is kept in the address allocation mode for subsequent address allocation, and if not, the slave machine exits the address allocation mode so as not to process the command broadcast by the master machine and related to address allocation.
For example, if the slave determines that the start address allocation command corresponds to the no address allocation command, the slave determines whether it currently has an address, and if not, it remains in the address allocation mode, and if so, it exits the address allocation mode. If the slave determines that the start address allocation command corresponds to the predetermined address allocation command, the slave judges whether the slave currently has a predetermined address in the command, and if so, the slave is kept in an address allocation mode; if no predetermined address is present, the address assignment mode is exited. If the slave determines that the start allocation address command corresponds to a forced allocation command, the slave remains in the address allocation mode.
In the case where the slave determines that it needs to remain in the address allocation mode, if the slave currently has an address (e.g., in the case where the start allocation address command corresponds to a predetermined address allocation command or a forced allocation command), it may clear the address in preparation for being allocated a new address.
It should be understood that the above is only one example of the slave responding to the start address allocation command, and the slave may respond to the command in other manners, for example, the slave may first determine whether it belongs to the slave indicated by the start address allocation command, and may not enter the address allocation mode if it is determined that it does not belong to the slave indicated by the command, and may enter the address allocation mode if it is determined that it belongs to the slave indicated by the command.
After or simultaneously with the broadcast of the start assignment address command by the master, a random number generation command is broadcast so that at least one slave (the above slave entering the address assignment mode) generates a random number at step S120. Here, the slave in the above address allocation mode can generate a random number in response to a random number generation command.
In one embodiment, the random number generation command may include a random number upper value and a random number lower value. The random number generation command may cause each of the at least one slave machines to generate a random number that is less than the random number upper limit value and greater than the random number lower limit value.
As an example, the random number upper limit value may be at least ten times the number of slaves to which addresses are to be assigned as determined by the master, so that when the slaves generate random numbers, the possibility of different slaves generating duplicate random numbers is avoided. For example, in the case where the number of slaves to which addresses are to be allocated is 10, the random number upper limit value may be 100, the random number lower limit value may be 0, and the random numbers generated by the respective slaves may be a positive integer (n) smaller than 100 and greater than 0.
In step S130, feedback information of the at least one slave in response to the generated random number is acquired to determine a target slave among the at least one slave.
For example, after the slave generates the random number (n), it may wait for a further command from the master to send relevant information to the master in response to the further command, so that the master can determine a target slave to which the master will currently assign an address according to the information. As an example, the target slave may be a slave that generates a minimum random number having a minimum value among random numbers generated by at least one slave. Step S130 will be further described below with reference to fig. 2 to 5.
In step S140, an address is assigned to the target slave.
In one embodiment, step S140 may include: generating a target address according to the minimum random number; and broadcasting the target address so that the target slave has the target address. Step S140 will be further described below with reference to fig. 2 to 5.
In this way, the address assignment to one of the slaves that is the target, for example, the slave that generates the smallest random number, can be completed. At this point, the target slave to which the address is assigned may exit the address assignment mode to no longer process commands associated with the assigned address that are subsequently broadcast by the master.
In order to enable the master to sequentially assign addresses to the slaves in the case that the master needs to assign addresses to a plurality of slaves, in one embodiment, the method for assigning addresses of the master according to the present invention may further include (refer to fig. 4): determining whether the number of times of assigning addresses reaches a predetermined value after assigning addresses to the target slave (S150); in the case where the predetermined value is not reached, repeatedly performing step S120 (broadcasting a random number generation command including a new random number upper limit value and a new random number lower limit value at this time), step S130 (determining a target slave), and step S140 (assigning an address to the target slave); in the case where the number of times of allocating addresses reaches a predetermined value, an end address allocation command is broadcast (S160) so that there is no slave in the address allocation mode. If the slave machine still exists in the address allocation mode, the command of ending the address allocation can force the slave machine to exit the address allocation mode; if all slaves have exited the address assignment mode at this point, the slaves may not perform any processing on the end assign address command.
Fig. 2 shows a flowchart of a method of allocating an address for a host according to another exemplary embodiment of the present invention.
Referring to fig. 2 and 1, steps S110, S120, and S140 in fig. 2 are the same as in fig. 1 except that: fig. 2 shows an example of step S130 in fig. 1 in steps S131-S135.
Referring to fig. 2, in step S131, a random number matching command may be broadcast, and the random number matching command may include a random number matching condition.
In one embodiment, the random number matching condition may be a random number matching value (M), and the random number matching command is used to cause a slave that produces an address less than or equal to the random number matching value (n ≦ M) to enter an address state to be assigned. For example, the address to be allocated state may be a state in which the slave sets its matching flag (flag) so that it can be allocated an address. Meanwhile, a slave that generates more than a random number matching value (n > M) may enter an unallocated address state, for example, the slave may reset (clear) its matching flag to be in a state in which it cannot be allocated an address.
In step S132, a response of at least one slave to the random number matching command may be acquired. This will be further described below with reference to fig. 3 and 4.
In step S133, it may be determined whether the random number matching condition (e.g., the random number matching value M) needs to be updated according to the response so that only the target slave (having the smallest random number) of the at least one slave (having entered the address assignment mode) can enter the address to be assigned state.
In the case where it is determined in step S133 that the random number matching condition needs to be updated, the random number matching condition may be updated in step S134 and the process returns to step S131 to broadcast a random number matching command with the updated random number matching condition to further determine whether only the target slave enters the address to be allocated state under the adjusted random number matching condition.
In the case where it is determined in step S133 that the random number matching condition does not need to be updated, it may be determined in step S135 that only the target slave has entered the to-be-assigned address state, and the random number matching condition corresponds to the minimum random number. This will be further described below with reference to fig. 3 to 5.
Thereafter, step S140 of assigning an address to the target slave may be performed.
Fig. 3 shows a flowchart of a method of allocating an address for a host according to another exemplary embodiment of the present invention.
Fig. 3 differs from fig. 2 in that: fig. 3 shows an example of step S132 in further detail, and shows an example of step S133 in detail from step S133-1 to step S133-3.
In one embodiment, step S132 may include: whether indication information (sent from one or more slaves) is received or not is determined within a preset time, and the indication information can be information which is sent by the slave entering the address to be allocated and indicates that the slave enters the address to be allocated. For example, a slave that has set the match flag may send indication information to the master.
In the case where it is determined in step S132 that the indication information is received, step S133-1 of obtaining an intermediate value (M) through the first setting using the random number matching value (M) may be performed 11 ). In the case where it is determined in step S132 that the indication information is not received, step S133-2 of obtaining an intermediate value (M) through the second setting using the random number matching value (M) may be performed 11 )。
In step S133-3, it may be determined whether the intermediate value satisfies a predetermined criterion.
In the case where it is determined at step S133-3 that the intermediate value satisfies the predetermined criterion, it may be determined that the random number matching value does not need to be updated, and it may be determined at step S135 that only the target slave has entered the to-be-assigned address state. Thereafter, step S140 of allocating an address to the target slave may be performed.
In the case where it is determined in step S133-3 that the intermediate value does not satisfy the predetermined criterion, it may be determined that the random number matching value needs to be updated, and the random number matching value (M) may be updated to the intermediate value (M) obtained through the first setting or the second setting as above in step S134 11 ) And returns to the step S131, the random number matching command in which the random number matching value is updated to the current intermediate value is broadcastedTo further determine whether only the target slave has entered the to-be-assigned address state in this case.
In one example, the intermediate value M may be obtained (using bisection) through the following equation in step S133-1 and step S133-2 11
M 11 =(M 1 +M 2 )/2
Wherein M is 11 Represents the currently obtained intermediate value, and M 11 Is equal to (M) 1 +M 2 ) The value of the integer part of/2. M 1 May be a random number upper limit value (a), M 2 May be the random number lower limit value (b). M is a group of 11 、M 1 、M 2 A and M can be positive integers, and b can be 0.
In this case, the first setting in step S133-1 may be to set the current random number matching value (M) to M 1 The second setting in step S133-2 may be to set the current random number matching value (M) to M 2
Accordingly, in one embodiment, the predetermined criterion in step S133-3 may be the median value M 11 M with current setting 1 Or M 2 Are equal. In addition, at the current intermediate value M 11 When the predetermined standard is satisfied, M is currently set 1 I.e. the smallest random number.
For example, at the currently obtained intermediate value M 11 M at this time 1 Or M 2 When equal, represent M 1 And M 2 Are adjacent integers. Furthermore, M 1 And M 2 One of the two is the matching value M of the random number at this time, so that this can indicate that only one slave which generates the minimum random number enters the state of the address to be allocated, and the minimum random number is M 1
For example, when the random number upper limit value is 100 and the random number lower limit value is 0, M 1 May be 100,m 2 May be 0, and further, the random number matching value therein may be set to 99 at the time of the first broadcast random number matching command. After that, the indication information sent from the slave is receivedIn this case, M in the above equation may be set by the first setting 1 Is set to 99, at which time M 2 Is 0, so the currently calculated median value M 11 Is (M) 1 +M 2 ) The value of the integer part of/2 is 49. Since the middle value M is now 11 =49 and M 1 =99 or M 12 =0 is different, and therefore the predetermined condition is not satisfied, at which time the random number matching value M is updated to M = M 11 =49, namely, dividing M by two to accelerate the speed of searching the minimum random number; and so on until finding M, M which meets the above predetermined condition 1 And M 2 Until now. It should be understood that the above specific values are merely examples, and the values may be set to any other values according to actual needs.
Fig. 4 illustrates a flowchart of a method of allocating an address for a host according to another exemplary embodiment of the present invention.
Fig. 4 differs from fig. 3 in that: fig. 4 shows one example of step S133 in detail in steps S133-1 to S133-3, and shows step S150 and step S160 described in fig. 1.
In order to determine whether this is the case where no indication information is received after step S131 in the current cycle is performed for the first time (i.e., no slave generates a random number) in step S132, and thus no subsequent operation for allocating an address is required (since no slave can be allocated an address), in one embodiment, in the case where no indication information is received in step S132, step S133-4 may be performed first, and it is determined whether a random number matching command is currently broadcast for the first time after the random number generation command is broadcast, and in the case where it is determined in step S133-4 that a random number matching command is broadcast for the first time, step S160 may be performed, and an address allocation command is broadcast to end, so that there is no slave in the address allocation mode. In the case where it is determined in step S133-4 that the random number matching command is not broadcast for the first time after the random number generation command is broadcast, step S133-2 may be performed to obtain an intermediate value through the second setting using the random number matching value.
In one example, the determination can be madeCurrent M in the above equation 1 Is equal to the random number upper limit value a to determine whether the random number match command is currently broadcast the first time after the random number generation command is broadcast. For example, when M 1 (= a time (M)) 1 When it is an initial value), it may be determined that the random number matching command is broadcast for the first time, otherwise it may be determined that the random number matching command is not broadcast for the first time.
One example of the interaction process of the master and the slave in the process of the master allocating an address is described below with reference to fig. 5.
Fig. 5 shows a flowchart of a process in which a master assigns addresses to slaves, according to an example embodiment of the present invention.
Referring to fig. 5, the master 100 broadcasts a start assignment address command to all slaves 200 in step S501. Only one slave 200 is schematically shown in fig. 5, it being understood that each slave 200 associated with master 100 may perform the process shown in fig. 5.
In step S502, the slave 200 determines whether it is the slave indicated by the start allocation address command in response to the start allocation address command. If so, enter address assignment mode (and clear its current address if needed) and wait for further commands by host 100; if not, step S522 is executed to exit the address assignment mode (or not enter the address assignment mode).
In step S503, the host 100 broadcasts a random number generation command (including a random number upper limit value a and a random number lower limit value b).
In step S504, the slave 200 (which has entered the address allocation mode) generates a random number n (b < n < a) in response to the random number generation command.
In step S505, the host 100 broadcasts a random number matching command (including a random number matching value M).
In step S506, the slave 200 determines whether the random number it generates satisfies n ≦ M. If n is not more than M, entering an unallocated address state (resetting the matching flag thereof) in step S507, and returning to the step of continuously receiving the next random number matching command; if n is equal to or less than M, the state of the address to be allocated is entered (its matching flag is set) in step S508, and the indication information is sent to the host in step S509.
In step S510, the master 100 determines whether indication information of any slave 200 is received. If the indication information is received, M is transmitted to the mobile station at step S511 1 Set to the current value of M to obtain the intermediate value M in step S512 11 . If the indication information is not received, it is determined that M is received at step S513 1 Whether it is the random number upper limit value a, if M 1 If = a, it means that no slave needs to be assigned an address currently, step S521 is executed to broadcast an end-of-address-assignment command, if M is greater than 1 Not equal to a, if it indicates that the slave has entered the distributable address state before, then M is added in step S514 2 Set to the current value of M to obtain the intermediate value M at step S512 11
In step S515, the host 100 determines the currently obtained intermediate value M 11 Whether or not to the current M 1 Or M 2 Are equal. If not, step S516 is executed to update the random number matching value in the random number matching command to the current intermediate value M 11 And go back to step S505 to rebroadcast the random number matching command. If M is 11 With the current M 1 Or M 2 If they are equal, the master 200 may determine that the slave currently generating only the minimum random number is in the state of the assignable address and determine the current M at step S517 1 An address matching the random number is acquired for the random number generated by the slave and broadcast at step S518 so that the slave 200 saves the address at step S519. Thereafter, the slave to which the address is assigned may exit the address assignment mode at step S522.
It should be appreciated that steps S505-S516 may be repeated multiple times before step S518.
The host computer may determine whether a set value of the number of dispensations is reached at step S520. If not, the process returns to step S503 to broadcast a new random number generation command to assign an address to the next slave. If the number of times of assignment reaches the set value, step S521 is performed to broadcast an end assignment address command. Thereafter, in step S522, any slave 200 may exit the address assignment mode.
It should be understood that fig. 5 does not show all steps performed by the master 100 and each slave 200, for example, if an end assignment address command broadcasted by the master is received during any step of the slave performing thereof, the slave may immediately perform S522 a step of exiting the address assignment mode.
In addition, in order to enable the master and the slave to transmit the command or the information without influencing other data transmission on the connection bus (such as the RS485 bus), the master and the slave can check whether the data transmission is in progress on the bus before performing the transmission operation each time, and start to transmit the command or the information related to the above operation without data transmission.
In one example, the host may be caused to start transmitting (broadcasting) the command after detecting that there is no data transmission on the connection bus for a time t 1; the slave may be caused to start transmitting the relevant information after detecting that there is no data transmission on the connection bus for a time t 2. Further, t1 may be made larger than t2, for example, t1 is made three times or more as large as t2, to ensure the effectiveness of transmission.
In addition, during the process of performing the address allocation by the master, for example, a situation may occur in which a slave cannot send instruction information to the master although it can enter the state of an address to be allocated, which may cause the master to repeat the case of determining that the allocation frequency does not reach the set value in step S520 and returning to perform step S530, in order to prevent the master from repeatedly performing the above operations due to such an error, according to one embodiment, a threshold frequency for repeatedly performing the above operations may be set, and after repeatedly performing the above operations for the threshold frequency, the master broadcasts an end address allocation command to end the address allocation process, thereby saving the computational resources of the master. Optionally, the host may also report the error information to further determine the cause of the error in order to start the next address assignment process.
According to the method for allocating the address of the master, the master can broadcast the relevant command to the slave so that the slave generates the random number, and the slave is automatically allocated with the address by using the random number, so that the efficiency of allocating the address is improved, and the cost of allocating the address is saved.
Fig. 6 shows a block diagram of an apparatus 600 for allocating an address for a host according to an exemplary embodiment of the present invention.
Referring to fig. 6, the apparatus 600 for assigning an address of a host according to an exemplary embodiment of the present invention may be implemented by any processor and may include a first broadcasting unit 610, a second broadcasting unit 620, a determining unit 630, and an address assigning unit 640.
The first broadcasting unit 610 is configured to broadcast a start allocation address command to cause at least one of all slaves associated with the master to enter an address allocation mode.
The second broadcasting unit 620 is configured to broadcast a random number generation command to cause the at least one slave to generate a random number.
The determining unit 630 is configured to acquire feedback information of the at least one slave in response to the generated random number to determine a target slave among the at least one slave.
The address assignment unit 640 is configured to assign an address to the target slave.
In other words, the apparatus 600 for allocating an address of a host according to an exemplary embodiment of the present invention may perform any of the steps/operations in the methods described above with reference to fig. 1 to 5.
Examples of the start assignment address command, the random number generation command, the determination of the target slave, and the assignment of an address to the target slave have been described in detail above with reference to fig. 1 to 5, and are not described again here.
According to the device for allocating the address of the master, the slave can generate the random number by broadcasting the relevant command to the slave through the master, and the address can be automatically allocated to the slave by using the random number, so that the efficiency of allocating the address is improved, and the cost of allocating the address is saved.
There is also provided, in accordance with an embodiment of the present disclosure, a computer-readable medium having instructions stored thereon, which, when executed by a processor, may cause the processor to perform the above method of allocating an address for a host in accordance with an embodiment of the present disclosure.
It is to be understood that this disclosure is not limited to the particular configurations and processes described above and shown in the drawings. A detailed description of known methods is omitted herein for the sake of brevity. In the above embodiments, several specific steps are described and shown as examples. However, the method processes of the present invention are not limited to the specific steps described and illustrated, and those skilled in the art can make various changes, modifications and additions or change the order between the steps after comprehending the spirit of the present invention.
The functional blocks shown in the above-described structural block diagrams may be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, it may be, for example, an electronic circuit, an Application Specific Integrated Circuit (ASIC), suitable firmware, plug-in, function card, or the like. When implemented in software, the elements of the invention are the programs or code segments used to perform the required tasks. The program or code segments may be stored in a machine-readable medium or transmitted by a data signal carried in a carrier wave over a transmission medium or a communication link. A "machine-readable medium" may include any medium that can store or transfer information. Examples of a machine-readable medium include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio Frequency (RF) links, and so forth. The code segments may be downloaded via computer networks such as the internet, intranet, etc.
The present invention may be embodied in other specific forms without departing from its spirit or essential characteristics. For example, the algorithms described in the specific embodiments may be modified without departing from the basic spirit of the invention. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein.

Claims (16)

1. A method of allocating addresses for a host, comprising:
broadcasting a start allocation address command to cause at least one slave of all slaves associated with the master to enter an address allocation mode;
broadcasting a random number generation command to cause the at least one slave to generate a random number;
obtaining feedback information of the at least one slave machine in response to the generated random number to determine a target slave machine of the at least one slave machine; and
and allocating an address to the target slave.
2. The method of claim 1, wherein the start allocate address command comprises: a no address assignment command, a predetermined address assignment command, or a forced assignment command,
wherein the no address allocation command is used to cause all slaves not having an address to enter the address allocation mode,
the predetermined address allocation command is for causing a slave having a predetermined address among all slaves to enter the address allocation mode,
the force allocation command is used to bring all slaves into the address allocation mode,
wherein the slave in the address allocation mode is capable of generating a random number in response to the random number generation command.
3. The method according to claim 1, wherein the random number generation command includes a random number upper limit value and a random number lower limit value,
wherein the random number generation command is such that the random number generated by each of the at least one slave is less than the random number upper limit value and greater than the random number lower limit value,
wherein the target slave is a slave that generates a minimum random number having a minimum value among random numbers generated by the at least one slave.
4. The method of claim 3, wherein obtaining feedback information of the at least one slave in response to generating the random number to determine a target slave of the at least one slave comprises:
broadcasting a random number matching command, the random number matching command including a random number matching condition;
acquiring a response of the at least one slave to the random number matching command;
determining whether the random number matching condition needs to be updated or not according to the response so that only the target slave in the at least one slave can enter an address state to be allocated;
under the condition that the random number matching condition needs to be updated, updating the random number matching condition, and re-executing the steps of broadcasting the random number matching command, acquiring the response and determining whether the random number matching condition needs to be updated; and
determining that only the target slave enters the to-be-assigned address state in a case where it is determined that the random number matching condition does not need to be updated, and the random number matching condition corresponds to the minimum random number.
5. The method according to claim 4, wherein the random number matching condition is a random number matching value, the random number matching command is for causing a slave that has generated the random number matching value or less to enter the to-be-assigned address state,
wherein obtaining the response of the at least one slave to the random number matching command comprises:
and determining whether indication information is received within preset time, wherein the indication information is information which is sent by the slave machine entering the address state to be allocated and indicates that the slave machine enters the address state to be allocated.
6. The method of claim 5, wherein determining whether the nonce matching condition needs to be updated based on the response comprises:
obtaining an intermediate value through a first setting using the random number matching value in a case where it is determined that the indication information is received;
determining whether the intermediate value meets a predetermined criterion;
determining that the random number matching value does not need to be updated and determining that only the target slave enters the state of the address to be allocated under the condition that the intermediate value is determined to meet the predetermined standard;
determining that the random number match value needs to be updated if it is determined that the intermediate value does not satisfy the predetermined criterion,
wherein the nonce matching value is updated to the intermediate value.
7. The method of claim 6, wherein determining whether the nonce matching condition needs to be updated in accordance with the response further comprises:
obtaining an intermediate value through a second setting using the random number matching value in a case where it is determined that the indication information is not received;
determining whether the intermediate value meets the predetermined criteria;
determining that the random number matching value does not need to be updated and determining that only the target slave enters the state of the address to be allocated under the condition that the intermediate value is determined to meet the predetermined standard;
determining that the random number match value needs to be updated if it is determined that the intermediate value does not satisfy the predetermined criterion,
wherein the nonce matching value is updated to the intermediate value.
8. The method of claim 7, wherein determining whether the nonce matching condition needs to be updated based on the response further comprises:
determining whether the random number matching command is currently broadcast for the first time after the random number generation command is broadcast, in a case where the indication information is not received;
in a case where the random number matching command is not broadcast for the first time, the intermediate value is obtained by a second setting using the random number matching value.
9. The method of claim 8, wherein in a case where the random number matching command is broadcast for the first time, broadcasting an end assignment address command so as not to have a slave in the address assignment mode.
10. The method of claim 8, wherein the intermediate value is obtained using the nonce matching value by the following equation:
M 11 =(M 1 +M 2 )/2
wherein, M 11 Represents the intermediate value, and M 11 Is equal to (M) 1 +M 2 ) The value of the integer part of/2,
wherein the first setting sets the nonce matching value to M 1 The second setting is to set the random number match value to M 2
Wherein M is 1 Is the random number upper limit value, M 2 Is the random number lower limit value, wherein M 11 、M 1 、M 2 The random number matching value and the random number upper limit value are positive integers.
11. The method of claim 10, wherein the predetermined criterion is the median value M 11 M with current setting 1 Or M 2 The number of the first and the second antennas is equal,
wherein M is currently set in the case that the intermediate value satisfies the predetermined criterion 1 Is the minimum random number.
12. The method of claim 11, wherein the step of assigning an address to the target slave comprises:
generating a target address according to the minimum random number; and
broadcasting the target address so that the target slave has the target address.
13. The method according to any one of claims 1-12, further comprising:
after the address is allocated to the target slave machine, determining whether the number of times of allocating the address reaches a preset value;
under the condition that the preset value is not reached, the steps of broadcasting the random number generation command, obtaining the feedback information and allocating an address to the target slave machine are repeatedly executed;
in case the predetermined value is reached, broadcasting an end allocation address command so that there are no slaves in the address allocation mode.
14. The method of any of claims 1-12, wherein the master is associated with each slave through an RS485 bus.
15. An apparatus for assigning addresses for a host, comprising:
a first broadcasting unit configured to broadcast a start allocation address command to cause at least one slave among all slaves associated with a master to enter an address allocation mode;
a second broadcasting unit configured to broadcast a random number generation command to cause the at least one slave to generate a random number;
a determining unit configured to acquire feedback information of the at least one slave in response to the generated random number to determine a target slave among the at least one slave; and
an address allocation unit configured to allocate an address to the target slave.
16. A computer readable medium having stored thereon instructions which, when executed by a processor, cause the processor to carry out the method of assigning addresses for hosts according to any one of claims 1-14.
CN202211548422.3A 2022-12-05 2022-12-05 Method and apparatus for allocating addresses for hosts Pending CN115987947A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211548422.3A CN115987947A (en) 2022-12-05 2022-12-05 Method and apparatus for allocating addresses for hosts

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211548422.3A CN115987947A (en) 2022-12-05 2022-12-05 Method and apparatus for allocating addresses for hosts

Publications (1)

Publication Number Publication Date
CN115987947A true CN115987947A (en) 2023-04-18

Family

ID=85960273

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211548422.3A Pending CN115987947A (en) 2022-12-05 2022-12-05 Method and apparatus for allocating addresses for hosts

Country Status (1)

Country Link
CN (1) CN115987947A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116962351A (en) * 2023-09-18 2023-10-27 上海红檀智能科技有限公司 Automatic communication address allocation method and device for Internet of things circuit breaker

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116962351A (en) * 2023-09-18 2023-10-27 上海红檀智能科技有限公司 Automatic communication address allocation method and device for Internet of things circuit breaker
CN116962351B (en) * 2023-09-18 2023-12-29 上海红檀智能科技有限公司 Automatic communication address allocation method and device for Internet of things circuit breaker

Similar Documents

Publication Publication Date Title
US8385336B2 (en) Communication apparatus and communication method
US8705486B2 (en) Methods and apparatus for scheduling peer to peer traffic in cellular networks
US7912110B2 (en) Base station apparatus, wireless communication system and frequency assignment method
US20170079069A1 (en) Competition-based resource selection method and device, and computer storage medium
CN115987947A (en) Method and apparatus for allocating addresses for hosts
CN103379650B (en) A kind of decision method of resource collision and device
CN109121096B (en) Method and apparatus for determining broadcast nodes in a mesh network
CN104144024B (en) Time slot state update method and equipment
CN113971087A (en) Task allocation method, device and system and computer storage medium
CN108513361A (en) channel access method, device and storage medium
CN109639507B (en) Broadband power line carrier communication network upgrading method
CN106982469B (en) resource scheduling and collision indication method and equipment
CN113259490B (en) Multi-level node network data transmission method based on UDP transmission protocol
CN116016605A (en) Networking method and device for center node and terminal node of Internet of things
CN110876133B (en) Internet of vehicles information updating method, terminal and network equipment
CN116847432A (en) Subnet fusion method and device, electronic equipment and storage medium
CN114124275B (en) Time synchronization method, device, equipment and storage medium
CN115379592A (en) Data link establishing method, device, equipment and storage medium
TW202425604A (en) Method and device for allocating addresses for a host
CN112888063A (en) Remote terminal network access method, system, electronic device and storage medium
JP2006319942A (en) Network system
US20140286257A1 (en) Method and apparatus for performing control channel scheduling in orthogonal frequency division multiplexing access (ofdma)-based wireless mesh network
JPH11177530A (en) Low speed frequency hopping spread spectrum communication method and radio communication system using the communication method
CN113038570B (en) Access control method, device, equipment and storage medium of user node
JP2019033326A (en) Wireless device and program

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