Target Information Generation Method, Apparatus, Device, Medium and Embedded System

By detecting the unique identification information of the processor in the embedded device to generate the MAC address, the problems of human error and inflexible connection in the prior art are solved, the accuracy and mass production efficiency of the MAC address are improved, and the operation process is simplified.

CN115941644BActive Publication Date: 2025-08-05BEIJING CHJ AUTOMOTIVE TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111013391.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-31
Publication Date
2025-08-05
Estimated Expiration
2041-08-31

AI Technical Summary

Technical Problem

In the prior art, when allocating MAC addresses to embedded devices, there are human errors that cause errors to increase mass production time, and the equipment and database connections are inflexible, affecting mass production efficiency.

Method used

By detecting whether the target information is set in the processor, the unique identification information of the target device connected to the processor is obtained, and the target information is generated based on the unique identification information, such as the MAC address, avoiding early burning and database connection, and using logical operations to adjust it to a unicast address.

Benefits of technology

It improves the accuracy and mass production efficiency of MAC addresses, simplifies the operation process, realizes flexible correlation between devices and servers, and saves time in developing and maintaining databases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115941644B_ABST
    Figure CN115941644B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a method, apparatus, device, medium, and embedded system for generating target information. The method comprises: detecting whether target information is set in a processor; wherein the target information is used to identify the processor; when detecting that the target information is not set in the processor, obtaining unique identification information of a target device connected to the processor; and generating target information based on the unique identification information. According to the technical solution of the embodiment of the present disclosure, target information is generated based on the unique identification information of the target device, such as a MAC address, thereby eliminating the need to pre-burn the MAC address or set up a MAC address database. This saves the process of burning the MAC address or setting up the database, and allows for flexible generation of MAC addresses on demand to achieve flexible association between embedded devices and servers. This helps reduce the production process and time of embedded devices and improves production efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of network communication technology, and in particular to a method, device, equipment, medium and embedded system for generating target information. Background Art

[0002] With the rapid development of the Internet of Things (IoT), it is becoming increasingly important to connect multiple embedded devices to the same local area network (LAN), i.e., to coordinate multiple embedded devices through a single server. When an embedded device is connected to a LAN, it is necessary to assign unique identification information to the network interface card (NIC) of the central processing unit (CPU). This information can be represented by target information to distinguish different embedded devices. This target information can be the media access control address, i.e., the physical address (MAC) of the network interface card.

[0003] Taking the MAC address as an example, existing methods for setting the MAC address primarily involve pre-burning the MAC address into a non-volatile storage device, which the CPU can then read from during initialization. Alternatively, the MAC address is stored in a database, which the embedded device directly connects to, and the CPU can then read from the database during initialization. However, both methods have drawbacks. For example, pre-burning the MAC address requires setting up a burn-in procedure during the embedded device production process, which increases the operational process and time required for mass production, impacting mass production efficiency. Furthermore, human error can easily lead to MAC address errors, requiring the MAC address to be cleared and re-burned, further increasing the burn-in procedure during production and impacting mass production efficiency. Directly connecting the embedded device to the database requires a wired connection between the embedded device and the database server, which is inflexible. Furthermore, this method requires developing and maintaining the database, which is time-consuming and also results in lower mass production efficiency. Summary of the Invention

[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a target information generation method, device, equipment, medium and embedded system that can improve mass production efficiency.

[0005] In a first aspect, an embodiment of the present disclosure provides a method for generating target information, including:

[0006] Detecting whether target information is set in the processor; wherein the target information is used to identify the processor;

[0007] When it is detected that the target information is not set in the processor, obtaining unique identification information of a target device connected to the processor; wherein the target device and the processor are set in the same device;

[0008] Generate target information based on the unique identification information.

[0009] In some embodiments, generating target information based on the unique identification information includes:

[0010] Generate initial target information based on the unique identification information;

[0011] Based on the initial target information, when it is determined that the target condition is met, the initial target information is used as the target information; or

[0012] When it is determined based on the initial target information that the target condition is not met, the initial target information is adjusted so that the adjusted initial target information meets the target condition;

[0013] The adjusted initial target information is used as the target information.

[0014] In some embodiments, the target information is a media access control address; the target condition includes that the initial target information belongs to a unicast address;

[0015] Based on the initial target information, when it is determined that the target conditions are met, the initial target information is used as the target information, including:

[0016] Based on the initial target information, determining whether the initial target information belongs to a unicast address;

[0017] When the initial destination information belongs to a unicast address, using the initial destination information as a media access control address;

[0018] When it is determined based on the initial target information that the target condition is not satisfied, adjusting the initial target information so that the adjusted initial target information satisfies the target condition includes:

[0019] When the initial target information does not belong to a unicast address, the target bit byte of the initial target information is adjusted according to a preset adjustment method so that the adjusted initial target information belongs to a unicast address, and the adjusted initial target information is used as the media access control address.

[0020] In some embodiments, the unique identification information includes an M×N-bit binary number, and the target information and the initial target information both include an N-bit binary number; wherein M and N are both integers greater than 0;

[0021] Based on the unique identification information, generate initial target information, including:

[0022] Divide the M×N binary numbers into N groups, each group includes M binary numbers;

[0023] Based on the M-bit binary numbers in each group, logical operations are performed within the group to obtain an N-bit binary number;

[0024] The obtained N-bit binary number is used as the initial target information.

[0025] In some embodiments, the value of M is 2; logical operations are performed within each group based on the M-bit binary numbers, including:

[0026] Based on the two binary numbers of each group, at least one logical operation of exclusive-OR, AND-OR, and AND-OR is performed within the group.

[0027] In some embodiments, when an M×N-bit binary number is divided into N groups, every adjacent M bits form a group, or any different M bits form a group.

[0028] In some embodiments, detecting whether target information is set in the processor includes:

[0029] After the processor is powered on, read the status flags;

[0030] Based on the status flag, determine whether the target information is set.

[0031] In some embodiments, after generating target information based on the unique identification information, the method further includes:

[0032] The status flag is adjusted to correspond to the flag where the target information is set.

[0033] In a second aspect, the present disclosure further provides a target information generating device, including:

[0034] A detection module, configured to detect whether target information is set in the processor; wherein the target information is used to identify the processor;

[0035] an acquisition module, configured to acquire unique identification information of a target device connected to the processor when it is detected that the target information is not set in the processor; wherein the target device and the processor are set in the same device;

[0036] The generation module is used to generate target information based on the unique identification information.

[0037] In some embodiments, the generation module specifically includes:

[0038] A generation submodule, used to generate initial target information based on the unique identification information;

[0039] a determination submodule, configured to determine, based on the initial target information, that when the target condition is satisfied, use the initial target information as the target information; or

[0040] The determination submodule is also used to:

[0041] When it is determined based on the initial target information that the target condition is not met, the initial target information is adjusted so that the adjusted initial target information meets the target condition;

[0042] The adjusted initial target information is used as the target information.

[0043] In some embodiments, the target information is a media access control address; the target condition includes that the initial target information belongs to a unicast address;

[0044] The determination submodule is used to determine that the target conditions are met based on the initial target information and use the initial target information as the target information, specifically including:

[0045] Based on the initial target information, determining whether the initial target information belongs to a unicast address;

[0046] When the initial destination information belongs to a unicast address, using the initial destination information as a media access control address;

[0047] When the initial target information does not belong to a unicast address, adjusting the target bit byte of the initial target information according to a preset adjustment method so that the adjusted initial target information belongs to a unicast address;

[0048] The adjusted initial target information is used as a media access control address.

[0049] In some embodiments, the unique identification information includes an M×N-bit binary number, and the target information and the initial target information both include an N-bit binary number; wherein M and N are both integers greater than 0;

[0050] Generate submodules, specifically for:

[0051] Divide the M×N binary numbers into N groups, each group includes M binary numbers;

[0052] Based on the M-bit binary numbers in each group, logical operations are performed within the group to obtain an N-bit binary number;

[0053] The obtained N-bit binary number is used as the initial target information.

[0054] In some embodiments, the value of M is 2; the generating submodule is configured to perform logical operations within each group based on the M-bit binary numbers of each group, specifically including:

[0055] Based on the two binary numbers of each group, at least one logical operation of exclusive-OR, AND-OR, and AND-OR is performed within the group.

[0056] In some embodiments, when an M×N-bit binary number is divided into N groups, every adjacent M bits form a group, or any different M bits form a group.

[0057] In some embodiments, the detection module is used to detect whether the target information is set in the processor, specifically including:

[0058] After the processor is powered on, read the status flags;

[0059] Based on the status flag, determine whether the target information is set.

[0060] In some embodiments, the target information generating device further includes:

[0061] The status flag bit adjustment module is used to adjust the status flag bit to a flag bit corresponding to the target information after generating the target information based on the unique identification information.

[0062] In a third aspect, an embodiment of the present disclosure further provides an electronic device, comprising: a processor and a memory;

[0063] The processor is configured to execute the steps of any one of the methods provided in the first aspect by calling a program or instruction stored in the memory.

[0064] In a fourth aspect, an embodiment of the present disclosure further proposes a non-transitory computer-readable storage medium, characterized in that the non-transitory computer-readable storage medium stores a program or instruction, and the program or instruction enables a computer to execute the steps of any one of the methods provided in the first aspect.

[0065] In a fifth aspect, an embodiment of the present disclosure further provides an embedded system, comprising a server and at least one device connected to the server; each device comprises a processor and a target device;

[0066] The target device has unique identification information;

[0067] The processor executes the steps of any one of the methods provided in the first aspect to determine the target information based on the unique identification information.

[0068] The technical solution provided by the embodiments of the present disclosure has the following advantages over the prior art:

[0069] The technical solution provided by the embodiment of the present disclosure obtains the unique identification information of the target device connected to the processor when it is detected that the target information is not set in the processor, and generates the target information, such as a MAC address, based on the unique identification information. Therefore, there is no need to burn the MAC address in advance, which can avoid human errors and the problem of MAC address errors, thereby improving the accuracy of the MAC address; at the same time, since it saves the burning of the MAC address and the program of clearing and re-burning the MAC address when the MAC address is wrong, it can further save the program of clearing and re-burning the MAC address, thereby simplifying the operation process of mass production of embedded devices and improving mass production efficiency. At the same time, since there is no need to set up a database in this technical solution, there is no problem of low connection flexibility caused by the wired connection between the embedded device and the server that forms the database. Instead, the MAC address can be flexibly generated on demand to realize the flexible association between the embedded device and the server; at the same time, since there is no need to use a database to store the MAC address, it can save the program of developing and maintaining the database and the time required for the corresponding program, which is also conducive to improving mass production efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0071] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0072] Figure 1 A flowchart of a method for generating target information provided by an embodiment of the present disclosure;

[0073] Figure 2 A flowchart of a MAC address generation method provided in an embodiment of the present disclosure;

[0074] Figure 3 A schematic structural diagram of a target information generating device provided in an embodiment of the present disclosure;

[0075] Figure 4 A schematic structural diagram of an electronic device provided in an embodiment of the present disclosure;

[0076] Figure 5 A schematic diagram of the structure of an embedded system provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0077] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features therein can be combined with each other in the absence of conflict.

[0078] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0079] The target information generation method provided by the embodiment of the present disclosure is applicable to scenarios requiring unique coding and can be executed by a processor of an embedded device. The target information is unique information generated based on the unique identification information of the target device, and the target information is used to distinguish different embedded devices. It can be understood that the target information can be used to distinguish different embedded devices, or it can be understood that the target information is used to identify the processor, and the unique identification information can be used to distinguish different target devices, wherein the target device is a device in the embedded device, such as a microcontroller unit (MCU). When both the target information and the unique identification information are represented by binary numbers, the number of bits can be the same or different, which is not limited here.

[0080] Optionally, when the target information is a MAC address, when it is detected that the target information is not set in the processor, the unique identification information of the target device connected to the processor is obtained, and the target information is generated based on the unique identification information. For example, the MAC address can be generated based on the unique identification information. Therefore, since there is no need to burn the MAC address in advance, human errors can be avoided, and the problem of MAC address errors can be avoided, thereby improving the accuracy of the MAC address. At the same time, since the burning of the MAC address is saved and the procedure of clearing and re-burning the MAC address is further saved when the MAC address is wrong, the operation process of mass production of embedded devices can be simplified, and the mass production efficiency can be improved. At the same time, since there is no need to set up a database in this technical solution, there is no problem of low connection flexibility caused by the wired connection between the embedded device and the server that forms the database. Instead, the MAC address can be flexibly generated on demand to realize the flexible association between the embedded device and the server. At the same time, since there is no need to use a database to store the MAC address, the program for developing and maintaining the database can be saved, and the time required for the corresponding program can be saved, which is also conducive to improving mass production efficiency.

[0081] The following combination Figure 1-Figure 5 , an exemplary description is given of the target information generation method, apparatus, device, medium and embedded system provided in the embodiments of the present disclosure.

[0082] In some embodiments, Figure 1 A flow chart of a method for generating target information provided by an embodiment of the present disclosure. Figure 1 , the method comprising:

[0083] S110: Detect whether target information is set in the processor.

[0084] In the embodiment of the present disclosure, the target information is used to identify the processor, so the target information can also be used to distinguish different embedded devices; for example, the target information may be a MAC address.

[0085] In the embodiment of the present disclosure, it is first detected whether the target information has been set in the processor; if the target information has been set in the processor, the system, such as an embedded system, can be started directly, and other operations can be performed based on the target information that has been set, that is, the subsequent S120 and S130 are skipped; if the target information is not set in the processor, it is necessary to execute the subsequent S120 and S130 to generate the target information, and after the target information is generated, the system startup and other operations after the system startup can be executed.

[0086] In some embodiments, this step may specifically include:

[0087] After the processor is powered on, read the status flags;

[0088] Based on the status flag, determine whether the target information is set.

[0089] In the embodiment of the present disclosure, the status flag is used to indicate whether the target information is set in the processor. The status flag may correspond to two different states of the processor, namely, a state in which the target information is set and a state in which the target information is not set.

[0090] Exemplarily, the status flag may default to 0, which corresponds to no target information being set; if the status flag has been set, ie, set to 1, ie, the status flag is 1, it corresponds to target information being set.

[0091] Based on this, when the status flag is 0, it is determined that the target information is not set in the processor; when the status flag is 1, it is determined that the target information is set in the processor.

[0092] In this way, it is possible to conveniently and accurately determine whether the target information is set in the processor.

[0093] In other implementations, other methods known to those skilled in the art may be used to determine whether target information is set, which will not be elaborated or limited herein.

[0094] S120 : When it is detected that the target information is not set in the processor, obtain unique identification information of the target device connected to the processor.

[0095] In the disclosed embodiments, the unique identification information may also be referred to as a unique device identification code, which can be used to distinguish different target devices. For example, the unique identification information may be a user identification (UID). In other embodiments, the unique identification information may also be other unique information of the target device connected to the processor that can generate target information, which is not limited here.

[0096] In the embodiment of the present disclosure, the target device and the processor are arranged in the same device, and the connection between the target device and the processor can be a line connection or a communication connection, which is not limited here.

[0097] In an embodiment of the present disclosure, when it is detected that the target information is not set in the processor, unique identification information of the target device connected to the processor may be obtained for use in generating the target information in subsequent steps.

[0098] S130: Generate target information based on the unique identification information.

[0099] In the embodiment of the present disclosure, target information may be generated based on the unique identification information obtained in the aforementioned S120 , and a specific generation method is exemplified below.

[0100] In the target information generation method provided by the embodiment of the present disclosure, when it is detected that the target information is not set in the processor, the unique identification information of the target device connected to the processor is obtained, and the target information is generated based on the unique identification information, for example, a MAC address can be generated based on the UID. Therefore, since the MAC address does not need to be burned in advance, human errors can be avoided and the problem of MAC address errors can be avoided, thereby improving the accuracy of the MAC address; at the same time, since the burning of the MAC address is saved and the program of clearing and re-burning the MAC address is further saved when the MAC address is wrong, the operation process of mass production of embedded devices can be simplified and the mass production efficiency can be improved. At the same time, since there is no need to set up a database in this technical solution, there is no problem of low connection flexibility caused by the wired connection between the embedded device and the server that forms the database. Instead, the MAC address can be flexibly generated on demand to realize the flexible association between the embedded device and the server; at the same time, since there is no need to use a database to store the MAC address, the program for developing and maintaining the database can be saved, and the time required for the corresponding program can be saved, which is also conducive to improving mass production efficiency.

[0101] Combined with the above Figure 1 The entire process of the target generation method provided by the embodiment of the present disclosure is exemplarily described. The specific implementation of S130 in the method is exemplarily described below.

[0102] In some embodiments, Figure 1 Based on this, S130 may specifically include:

[0103] Generate initial target information based on the unique identification information;

[0104] Based on the initial target information, when it is determined that the target condition is met, the initial target information is used as the target information; or

[0105] When it is determined based on the initial target information that the target condition is not met, the initial target information is adjusted so that the adjusted initial target information meets the target condition;

[0106] The adjusted initial target information is used as the target information.

[0107] In the embodiment of the present disclosure, initial target information is first generated based on unique identification information, and then the initial target information is checked. When the initial target information meets the target condition, the initial target information is used as the target information; when the initial target information does not meet the target condition, the initial target information can be adjusted so that it can meet the target condition; and the adjusted initial target information that can meet the target condition is used as the target information.

[0108] In the embodiment of the present disclosure, the target condition may be a condition for verifying whether the initial target information is unique, or other verification conditions that the target information needs to meet.

[0109] In some embodiments, the target information includes a media access control address, ie, a MAC address; and the target condition includes that the initial target information belongs to a unicast address.

[0110] Based on this, the above “based on the initial target information, when determining that the target condition is met, using the initial target information as the target information” may specifically include:

[0111] Based on the initial target information, determining whether the initial target information belongs to a unicast address;

[0112] When the initial target information belongs to a unicast address, the initial target information is used as a MAC address.

[0113] In the embodiment of the present disclosure, a unicast address may also be referred to as a unicast MAC address, which refers to a MAC address in which the least significant bit of the first byte is 0. Taking a unicast address including 6 bytes as an example, it can be expressed as: xxxxxxx0-xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx; where x represents 0 or 1.

[0114] Based on this, it is determined whether the lowest bit of the first byte of the initial target information is 0. If so, the initial target information is used as the MAC address.

[0115] Furthermore, when it is determined based on the initial target information that the target condition is not met, the initial target information can be adjusted so that the adjusted initial target information can meet the target condition, and the adjusted initial target information can be used as the target information. An example is shown below.

[0116] In some embodiments, “based on the initial target information, when determining that the target condition is not satisfied, adjusting the initial target information so that the adjusted initial target information satisfies the target condition; and using the adjusted initial target information as the target information” may specifically include:

[0117] When the initial target information does not belong to a unicast address, adjusting the target bit byte of the initial target information according to a preset adjustment method so that the adjusted initial target information belongs to a unicast address;

[0118] The adjusted initial target information is used as a media access control address.

[0119] Exemplarily, the target bit byte may be the first byte, specifically the least significant bit of the first byte. The preset adjustment method may be to change the least significant bit of the first byte from "1" to "0", or to adopt other adjustment methods known to those skilled in the art, which are not limited here.

[0120] In the disclosed embodiment, when the initial destination information is not a unicast address, the initial destination information is a multicast address. A multicast address, also known as a multicast MAC address, refers to a MAC address in which the least significant bit of the first byte is 1. For example, a multicast address consisting of 6 bytes can be represented as: xxxxxxx1-xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx, where x represents 0 or 1.

[0121] In particular, a special case of a multicast address is a broadcast address, also known as a broadcast MAC address. It refers to a MAC address in which all bits of each byte are 1. Taking 6 bytes as an example, it can be expressed as: 11111111-11111111-11111111-11111111-11111111-111111111.

[0122] Based on this, when the initial target information belongs to a multicast address, the least significant bit of the first byte of the multicast address is changed from "1" to "0", and a MAC address with the least significant bit of the first byte being 0 is obtained. This MAC address belongs to a unicast address.

[0123] In this way, the initial target information is adjusted so that the adjusted initial target information meets the target condition, and the adjustment method is simple.

[0124] Hereinafter, the optional method of “generating initial target information based on the unique identification information” is exemplified by taking the case where both the unique identification information and the target information are binary numbers.

[0125] In some embodiments, the unique identification information includes an M×N-bit binary number, and the target information and the initial target information both include an N-bit binary number; wherein M and N are both integers greater than 0.

[0126] In the embodiment of the present disclosure, the number of bits of the unique identification information may be an integer multiple of the number of bits of the initial target information, and the number of bits of the initial target information may be equal to the number of bits of the target information.

[0127] Exemplarily, the value of N can be 24, 48, 96 or other positive integers, corresponding to the initial target information and the target information can be binary numbers of 24 bits, 48 bits, 96 bits or other bits, which are not limited here.

[0128] Exemplarily, the value of M can be 1, 2, 3 or other positive integers, and the number of bits corresponding to the unique identification information can be 1 times, 2 times, 3 times or other integer multiples of the number of bits of the initial target information, which is not limited here.

[0129] Based on this, in the above implementation, “generating initial target information based on the unique identification information” may specifically include:

[0130] Divide the M×N binary numbers into N groups, each group includes M binary numbers;

[0131] Based on the M-bit binary numbers in each group, logical operations are performed within the group to obtain an N-bit binary number;

[0132] The obtained N-bit binary number is used as the initial target information.

[0133] In the embodiment of the present disclosure, the M×N-bit binary numbers corresponding to the unique identification information are grouped into N groups, and each group includes an M-bit binary number; then the M-bit binary numbers in each group are logically operated within the group, and each group corresponds to a binary number, and the N groups correspond to N-bit binary numbers, which are used as the initial target information.

[0134] For example, logical operations can also be called binary logical operations, which only use two digital symbols 0 and 1. The operations are simple and convenient and can be easily implemented electronically.

[0135] In this way, initial target information can be generated by performing grouping logic operations on the unique identification information.

[0136] In some embodiments, the value of M is 2.

[0137] In the embodiment of the present disclosure, the number of bits of the unique identification information is twice the number of bits of the initial target information. Through logical operations, the number of bits of the unique identification information can be halved to meet the number requirement of the initial target information.

[0138] Exemplarily, the UID may be a 96-bit binary number, and the MAC address may be a 48-bit binary number, that is, in this method, a 48-bit MAC address may be generated based on the 96-bit UID.

[0139] Therefore, “performing logical operations within each group based on the M-bit binary numbers of each group” may specifically include:

[0140] Based on the two binary numbers of each group, at least one logical operation of exclusive-OR, AND-OR, and AND-OR is performed within the group.

[0141] Among them, by performing at least one logical operation of XOR, AND-OR, AND and OR, two-bit binary numbers can be converted into one-bit binary number, thereby generating N-bit initial target information based on 2N-bit unique identification information.

[0142] For example, the 96-bit UID can be XORed to obtain a 48-bit result, which can be used to set the MAC address. This can achieve automatic configuration on power-up and ensure the uniqueness of the MAC address.

[0143] The mathematical symbol for the XOR operation is “⊕”. The two binary numbers to be operated are represented by a and b respectively. When the XOR operation is performed on the two values ​​a and b, if the two values ​​a and b are different, the XOR result is 1; if the two values ​​a and b are the same, the XOR result is 0, as shown in Table 1.

[0144] Table 1 XOR operation table

[0145] a b a⊕b 0 0 0 0 1 1 1 0 1 1 1 0

[0146] Based on this, a 48-bit MAC address can be obtained by performing an XOR operation on each adjacent two bits of the 96-bit UID. At the same time, because the 96-bit UID is unique, the probability of the 48-bit MAC address being repeated after the XOR operation is 1 / (2 48 ), this extremely low probability can almost achieve the uniqueness of MAC addresses in a limited number of embedded devices within a local area network.

[0147] In other implementations, other logical operations proposed in the above embodiments may also be used, which are not limited here.

[0148] In the above embodiment, every two adjacent bits form a group; in other embodiments, a head-tail combination or other grouping methods may also be used.

[0149] In some embodiments, when an M×N-bit binary number is divided into N groups, each adjacent M bits constitutes a group.

[0150] This setting can make the grouping method simple.

[0151] In some embodiments, when an M×N-bit binary number is divided into N groups, any different M bits form a group.

[0152] This setting makes the grouping method flexible.

[0153] In some embodiments, after generating target information based on the unique identification information, the method may further include:

[0154] The status flag is adjusted to correspond to the flag where the target information is set.

[0155] Exemplarily, in combination with the above, when the status flag is 0 by default, and 0 corresponds to no target information being set; after the target information is generated, the status flag may also be adjusted to 1.

[0156] In some embodiments, the target device may be a microcontroller unit. In the embodiments of the present disclosure, when an embedded device has an MCU for peripheral control, for example, it may include simple input and output such as the input of sensor data and the output of control data, and the MCU has a 96-bit UID. When the CPU starts, it first detects whether the MAC address is set. If the MAC address has been set, it continues to start; if the MAC address is not set, the UID of the MCU is obtained. Since the MAC address is a 48-bit binary number, it is different from the number of bits of the UID of the MCU. Therefore, a 48-bit binary number can be obtained by performing XOR processing on the UID, and the 48-bit binary number is set as the MAC address. In this way, the MAC address can be flexibly and automatically configured when the CPU is powered on, and the uniqueness of the MAC address can be guaranteed, thereby solving the technical defects of the prior art of setting the MAC address by external means, thereby simplifying the MAC address setting process and improving mass production efficiency.

[0157] For example, Figure 2 The figure shows a flow chart of another target information generation method provided by the embodiment of the present disclosure, showing a method for automatically obtaining the UID of the MUC and automatically configuring the MAC address based on the UID. Figure 2 , the method may include the following steps.

[0158] S201. Power on the CPU.

[0159] That is, start the CPU.

[0160] S202: Check whether the MAC address is set.

[0161] That is, the status flag used to indicate whether the MAC address is set is read. The status flag is 0 by default, corresponding to the MAC address not being set; when the status flag is 1, it is set, corresponding to the MAC address being set.

[0162] Based on this, determine whether the MAC address is set.

[0163] If the MAC address has been set, that is, the status flag has been set (ie, "Y"), then jump directly to S208; if the MAC address has not been set, that is, the status flag is not set (ie, "N"), then execute subsequent S203-S207.

[0164] S203: Get the UID of the MCU.

[0165] That is, read the UID of the MCU.

[0166] S204: Obtain the MAC address through an XOR operation.

[0167] That is, after obtaining the 96-bit UID, the 48-bit MAC address is obtained through XOR operation.

[0168] S205: Detect whether the MAC address is a unicast address.

[0169] If the judgment result is no (N), execute S206; if the judgment result is yes (Y), execute S207.

[0170] S206: Set to the corresponding unicast address.

[0171] That is, if the MAC address obtained in S204 is not a unicast address, if it is a multicast address or a broadcast address, it is changed to the corresponding unicast address.

[0172] S207: Set the MAC address.

[0173] That is, the unicast address obtained in S204 or S206 is set as the MAC address.

[0174] After setting the MAC address, or while setting the MAC address, the method may further include: setting a status flag, that is, changing the status flag to 1.

[0175] S208: Start the system.

[0176] That is, start the embedded system.

[0177] The target information generation method provided by the embodiment of the present disclosure can automatically obtain the UID of the MCU when the MAC address is not set in the CPU, and obtain a MAC address that meets the target conditions through logical operations, optionally combined with subsequent adjustments. This can realize automatic configuration of the MAC address when the CPU is powered on, saving the process of burning the MAC address or additionally setting up and maintaining the database, reducing production procedures, and improving mass production efficiency.

[0178] In other implementations, the method may also be applied to other scenarios requiring configuration of unique codes, which are not limited here.

[0179] The embodiment of the present disclosure further proposes a target information generating device, which is used to execute the steps of any target information generating method proposed in the above method embodiments to achieve corresponding beneficial effects.

[0180] For example, Figure 3 FIG2 shows a schematic diagram of the structure of a target information generating device provided by an embodiment of the present disclosure. Figure 3 , the target information generating device 300 may include:

[0181] A detection module 310 is configured to detect whether target information is set in the processor; wherein the target information is used to identify the processor;

[0182] an acquisition module 320 for acquiring unique identification information of a target device connected to the processor when it is detected that the target information is not set in the processor; wherein the target device and the processor are set in the same device;

[0183] The generating module 330 is configured to generate target information based on the unique identification information.

[0184] In the target information generating device 300 provided by the embodiment of the present disclosure, through the cooperation between the above-mentioned functional modules, when it is detected that the target information is not set in the processor, the unique identification information of the target device connected to the processor can be obtained, and based on the unique identification information, the target information, such as the MAC address, can be generated. As a result, there is no need to burn the MAC address in advance, which can avoid human errors and the problem of MAC address errors, thereby improving the accuracy of the MAC address; at the same time, since the burning of the MAC address is saved and the program of clearing and re-burning the MAC address is further saved when the MAC address is wrong, the operation process of mass production of embedded devices can be simplified, thereby improving mass production efficiency. At the same time, since there is no need to set up a database in this technical solution, there is no problem of low connection flexibility caused by the wired connection between the embedded device and the server that forms the database. Instead, the MAC address can be flexibly generated on demand to realize the flexible association between the embedded device and the server; at the same time, since there is no need to use a database to store the MAC address, it can save the program of developing and maintaining the database and the time required for the corresponding program, thereby also helping to improve mass production efficiency.

[0185] In some embodiments, Figure 3 Based on this, the generation module 330 may specifically include:

[0186] A generation submodule, used to generate initial target information based on the unique identification information;

[0187] a determination submodule, configured to determine, based on the initial target information, that when the target condition is satisfied, use the initial target information as the target information; or

[0188] The determination submodule is also used to:

[0189] When it is determined based on the initial target information that the target condition is not met, the initial target information is adjusted so that the adjusted initial target information meets the target condition;

[0190] The adjusted initial target information is used as the target information.

[0191] In some embodiments, the target information is a media access control address; the target condition includes that the initial target information belongs to a unicast address;

[0192] The determination submodule is used to determine that the target conditions are met based on the initial target information and use the initial target information as the target information, specifically including:

[0193] Based on the initial target information, determining whether the initial target information belongs to a unicast address;

[0194] When the initial destination information belongs to a unicast address, using the initial destination information as a media access control address;

[0195] When the initial target information does not belong to a unicast address, adjusting the target bit byte of the initial target information according to a preset adjustment method so that the adjusted initial target information belongs to a unicast address;

[0196] The adjusted initial target information is used as a media access control address.

[0197] In some embodiments, the unique identification information includes an M×N-bit binary number, and the target information and the initial target information both include an N-bit binary number; wherein M and N are both integers greater than 0;

[0198] Generate submodules, specifically for:

[0199] Divide the M×N binary numbers into N groups, each group includes M binary numbers;

[0200] Based on the M-bit binary numbers in each group, logical operations are performed within the group to obtain an N-bit binary number;

[0201] The obtained N-bit binary number is used as the initial target information.

[0202] In some embodiments, the value of M is 2; the generating submodule is configured to perform logical operations within each group based on the M-bit binary numbers of each group, specifically including:

[0203] Based on the two binary numbers of each group, at least one logical operation of exclusive-OR, AND-OR, and AND-OR is performed within the group.

[0204] In some embodiments, when an M×N-bit binary number is divided into N groups, every adjacent M bits form a group, or any different M bits form a group.

[0205] In some embodiments, the detection module is used to detect whether the target information is set in the processor, specifically including:

[0206] After the processor is powered on, read the status flags;

[0207] Based on the status flag, determine whether the target information is set.

[0208] In some embodiments, the target information generating device further includes:

[0209] The status flag bit adjustment module is used to adjust the status flag bit to a flag bit corresponding to the target information after generating the target information based on the unique identification information.

[0210] It can be understood that the target information generating device 300 provided in the embodiment of the present disclosure can implement the steps of the target information generating method provided in any of the above method embodiments and achieve corresponding beneficial effects. The similarities can be understood by referring to the above and will not be repeated here.

[0211] An embodiment of the present disclosure further provides an electronic device, comprising: a processor and a memory; the processor calls a program or instruction stored in the memory to execute the steps of any one of the methods provided in the above method embodiments to achieve the corresponding effect.

[0212] For example, Figure 4 FIG2 shows a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 4 , the electronic device includes: at least one processor 401, at least one memory 402 and at least one communication interface 403. The various components in the electronic device are coupled together through a bus system 404. The communication interface 403 is used to transmit information between external devices. It can be understood that the bus system 404 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 404 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Figure 4 Various buses are labeled as bus system 404 .

[0213] It can be understood that the memory 402 in this embodiment can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories.

[0214] In some embodiments, the memory 402 stores the following elements, executable units or data structures, or a subset or an extended set thereof: an operating system and application programs.

[0215] The operating system includes various system programs, such as the framework layer, core library layer, and driver layer, which are used to implement various basic services and handle hardware-based tasks. The application program includes various application programs, such as media players and browsers, which are used to implement various application services. The program that implements the target information generation method provided in the embodiments of the present disclosure can be included in the application program.

[0216] In the embodiment of the present disclosure, the processor 401 calls the program or instructions stored in the memory 402, specifically, the program or instructions stored in the application, and the processor 401 is used to execute the steps of each embodiment of the target information generation method provided in the embodiment of the present disclosure.

[0217] The target information generation method provided by the embodiment of the present disclosure can be applied to the processor 401, or implemented by the processor 401. The processor 401 can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by an integrated logic circuit of hardware in the processor 401 or an instruction in the form of software. The above-mentioned processor 401 can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware component. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.

[0218] The steps of the target information generation method provided in the embodiments of the present disclosure can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software units in the decoding processor. The software units can be located in a storage medium well-known in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in memory 402, and processor 401 reads the information in memory 402 and combines it with hardware to complete the steps of the method.

[0219] The embodiments of the present disclosure also provide a non-transitory computer-readable storage medium, which stores programs or instructions. The programs or instructions enable a computer to execute the steps of each embodiment of the target information generation method. To avoid repeated description, they will not be repeated here.

[0220] An embodiment of the present disclosure also proposes an embedded system, including a server and at least one device connected to the server; each device includes a processor and a target device (such as a microcontroller unit); the target device has unique identification information; the processor executes the steps of each embodiment of the target information generation method to determine the target information based on the unique identification information.

[0221] For example, Figure 5 FIG2 shows a schematic diagram of the structure of an embedded system provided by an embodiment of the present disclosure. Figure 5 The embedded system may include a server 500 and an embedded device 510. The embedded device 510 is connected to the server 500. Each embedded device 510 may include a processor and a microcontroller unit. The processor may generate target information, such as a MAC address, based on the unique identification information of the microcontroller unit to achieve flexible automatic configuration of the MAC address.

[0222] It is understandable that Figure 5 In the embedded system shown in FIG, the number of embedded devices 510 is 4. In other embodiments, the number of embedded devices in the embedded system can also be any other number set by the user, which is not limited here.

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

[0224] The foregoing description is intended only to provide specific embodiments of the present disclosure, intended to enable those skilled in the art to understand and implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the embodiments described herein, but rather to be construed in the broadest manner consistent with the principles and novel features disclosed herein.

Claims

1. A method for generating target information, characterized in that: include: Detecting whether target information is set in the processor; wherein the target information is used to identify the processor; When it is detected that the target information is not set in the processor, obtaining unique identification information of a target device connected to the processor; generating the target information based on the unique identification information; The generating the target information based on the unique identification information includes: generating initial target information based on the unique identification information; When it is determined based on the initial target information that the target condition is met, the initial target information is used as the target information; or When it is determined based on the initial target information that the target condition is not satisfied, adjusting the initial target information so that the adjusted initial target information satisfies the target condition; the target condition includes a condition for verifying whether the initial target information is unique; using the adjusted initial target information as the target information; The unique identification information includes an M×N-bit binary number, and the target information and the initial target information both include an N-bit binary number; wherein M and N are both integers greater than 0; The generating of initial target information based on the unique identification information includes: Divide the M×N binary numbers into N groups, each group includes M binary numbers; Based on the M-bit binary numbers in each group, logical operations are performed within the group to obtain an N-bit binary number; The obtained N-bit binary number is used as the initial target information.

2. The method according to claim 1, characterized in that The target information is a media access control address; the target condition includes that the initial target information belongs to a unicast address; The determining, based on the initial target information, that the target condition is satisfied, using the initial target information as the target information includes: Based on the initial target information, determining whether the initial target information belongs to a unicast address; When the initial target information belongs to a unicast address, using the initial target information as the media access control address; When it is determined based on the initial target information that the target condition is not satisfied, adjusting the initial target information so that the adjusted initial target information satisfies the target condition includes: When the initial target information does not belong to a unicast address, the target bit byte of the initial target information is adjusted according to a preset adjustment method so that the adjusted initial target information belongs to a unicast address, and the adjusted initial target information is used as the media access control address.

3. The method according to claim 1, characterized in that The value of M is 2; the logical operations performed on the M-bit binary numbers in each group include: Based on the two binary numbers of each group, at least one logical operation of exclusive-OR, AND-OR, and AND-OR is performed within the group.

4. The method according to claim 1, wherein When dividing an M×N binary number into N groups, each adjacent M bits form a group, or any different M bits form a group.

5. The method according to claim 1, wherein The detecting whether target information is set in the processor includes: After the processor is powered on, reading the status flag bit; Based on the status flag, it is determined whether target information is set.

6. The method according to claim 5, characterized in that After generating the target information based on the unique identification information, the method further includes: The status flag is adjusted to correspond to the flag set with the target information.

7. A target information generating device, characterized in that: include: A detection module, configured to detect whether target information is set in the processor; wherein the target information is used to identify the processor; an acquisition module, configured to acquire unique identification information of a target device connected to the processor when detecting that the target information is not set in the processor; wherein the target device and the processor are set in the same device; A generating module, configured to generate the target information based on the unique identification information; The generation module specifically includes: A generation submodule, used to generate initial target information based on the unique identification information; a determination submodule, configured to determine, based on the initial target information, that when the target condition is satisfied, use the initial target information as the target information; or The determination submodule is further configured to: When it is determined based on the initial target information that the target condition is not satisfied, adjusting the initial target information so that the adjusted initial target information satisfies the target condition; the target condition includes a condition for verifying whether the initial target information is unique; The adjusted initial target information is used as the target information; The unique identification information includes an M×N-bit binary number, and the target information and the initial target information both include an N-bit binary number; wherein M and N are both integers greater than 0; The generation submodule is specifically used to: Divide the M×N binary numbers into N groups, each group includes M binary numbers; Based on the M-bit binary numbers in each group, logical operations are performed within the group to obtain an N-bit binary number; The obtained N-bit binary number is used as the initial target information.

8. An electronic device, characterized in that: include: processor and memory; The processor is configured to execute the steps of the method according to any one of claims 1 to 6 by calling the program or instructions stored in the memory.

9. A non-transitory computer-readable storage medium, characterized in that The non-transitory computer-readable storage medium stores a program or instruction, which enables a computer to execute the steps of the method according to any one of claims 1 to 6.

10. An embedded system, characterized in that: It includes a server and at least one device connected to the server; each device includes a processor and a target device; The target device has unique identification information; The processor executes the steps of the method according to any one of claims 1 to 6 to determine the target information based on the unique identification information.

Citation Information

Patent Citations

  • MAC address generation method and apparatus

    CN105430118A