Method and device for detecting hardware capabilities of embedded device, electronic device and medium

By querying the static mapping table and sub-board serial number during the embedded device startup phase, and combining the global capability structure to determine the configuration module capabilities, the problem of low efficiency in embedded device hardware capability detection is solved, achieving efficient and stable hardware capability identification and successful configuration.

CN123178145APending Publication Date: 2026-11-27XIAMEN MILESIGHT IOT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611359327.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-03
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing technologies for detecting the hardware capabilities of embedded devices are inefficient and prone to version drift and capability gaps, leading to detection failures.

Method used

During the startup phase of the embedded device, the basic capability bit set is obtained by querying the static mapping table, and the presence status of the dynamic extended sub-board is determined by combining the sub-board serial number. The capability bit set of the configuration module is determined by using the global capability structure, and the parsing and callback operations of the configuration module that do not conform to the preset capability mask field are skipped.

Benefits of technology

It improves the efficiency of hardware capability detection, reduces detection costs, avoids capability gaps, increases the success rate of device configuration, and supports accurate identification and stable use of dynamically expanded daughterboards.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123178145A_ABST
    Figure CN123178145A_ABST
Patent Text Reader

Abstract

This application provides a method, apparatus, electronic device, and medium for detecting the hardware capabilities of embedded devices, applied in the field of embedded device hardware feature recognition. During the embedded device startup phase, a basic capability bit set is obtained by querying the corresponding static mapping table based on the embedded device's device identifier; the daughterboard serial number of the embedded device is obtained, and the presence status of the dynamically extended daughterboard represented by the byte value at a preset byte position of the daughterboard serial number is determined to obtain a dynamic extended capability bit set; the current instance count of hardware resources is obtained, and the instance count, the basic capability bit set, and the dynamic extended capability bit set are written into a global capability structure. This ensures that during the configuration module execution phase, for each configuration module, if the capability bit set in the global capability structure does not contain all the capability bits required by the preset capability mask field corresponding to the configuration module, the parsing, verification, and application callback operations of that configuration module are skipped.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of embedded device hardware feature recognition, and in particular to a method, apparatus, electronic device and medium for detecting the hardware capabilities of embedded devices. Background Technology

[0002] In the field of Industrial Internet of Things (IIoT), when running embedded devices, it is necessary to first probe the hardware capabilities of the embedded devices to confirm their hardware capabilities (such as serial port function, positioning function, input / output function, etc.).

[0003] In related technologies, the common practice is to obtain independent capability description files written by the factory or capability lists downloaded from the cloud to probe the hardware capabilities of embedded devices. However, independent capability description files are prone to version drift compared to the actual hardware; and probing using cloud-downloaded capability lists can result in capability gaps. Both of these factors can lead to failures in probing the hardware capabilities of embedded devices, resulting in low probing efficiency. Summary of the Invention

[0004] The purpose of this application is to provide a method, apparatus, electronic device, and medium for detecting the hardware capabilities of embedded devices, so as to improve the detection efficiency of embedded device hardware capabilities. The specific technical solution is as follows: In a first aspect of this application, an embedded device hardware capability detection method is provided, the method comprising: During the startup phase of the embedded device, the corresponding static mapping table is queried according to the device identifier of the embedded device to obtain the basic capability bit set. The static mapping table records the in-situ status of each preset fixed hardware module. Obtain the daughterboard serial number of the embedded device, determine the dynamic expansion daughterboard presence status represented by the byte value of the daughterboard serial number at a preset byte position, and obtain the dynamic expansion capability bit set; wherein, the byte value of the daughterboard serial number at the preset byte position is preset during the manufacturing of the embedded device; Obtain the current number of hardware resource instances, and write the number of instances, the basic capability bit set, and the dynamic extended capability bit set into a global capability structure. This ensures that during the configuration module execution phase, for each configuration module, if the capability bit set in the global capability structure does not contain all the capability bits required by the preset capability mask field corresponding to the configuration module, the parsing, verification, and application callback operations of that configuration module are skipped.

[0005] In one possible implementation, obtaining the daughterboard serial number of the embedded device, determining the dynamic expansion daughterboard presence status represented by the byte value of the daughterboard serial number at a preset byte position, and obtaining the dynamic expansion capability bit set includes: Read the serial number of the embedded device's sub-board. If the reading fails, set the bit in the dynamic expansion capability bits that represents the state of the dynamic expansion sub-board to 0. If the read is successful, determine whether the byte value of the sub-board serial number at the preset byte position indicates that the dynamically extended sub-board is in place; If so, set the bit representing the in-bit state of the dynamic expansion capability bit to 1; If not, then set the bit representing the in-bit state of the dynamic expansion capability bit to 0.

[0006] In one possible implementation, skipping the parsing, verification, and application callback operations of the configuration module when the set of capability bits in the global capability structure does not contain all the capability bits required by the preset capability mask field corresponding to the configuration module includes: Perform a bitwise AND operation between the set of capability bits in the global capability structure and the preset capability mask field corresponding to the configuration module; If the result of the bitwise AND operation is not equal to the preset capability mask field, it is determined that the capability bit set does not contain all the capability bits required by the preset capability mask field, and the parsing, verification and application callback operations of the configuration module are skipped.

[0007] In one possible implementation, prior to the embedded device startup phase, the method further includes: Check if preset test environment variables exist; wherein, the preset test environment variables include the capability bits of each configuration module; If it exists, write the value of the preset test environment variable into the global capability structure.

[0008] In one possible implementation, determining the presence status of the dynamically extended subboard, represented by the byte value of the subboard serial number at a preset byte position, includes: When the byte value of the sub-board serial number at the preset byte position is 0, the presence status of the dynamic expansion sub-board is determined to be absent. When the byte value of the sub-board serial number at the preset byte position is non-zero, the in-situ state of the dynamic expansion sub-board is determined to be in-situ, and the type of the dynamic expansion sub-board is determined according to the byte value; wherein, different byte values ​​correspond to different types of dynamic expansion sub-boards.

[0009] In one possible implementation, during the configuration module execution phase, for each configuration module, when the set of capability bits in the global capability structure does not contain all the capability bits required by the preset capability mask field corresponding to the configuration module, the parsing, verification, and application callback operations of that configuration module are skipped, including: During the configuration module execution phase, for each configuration module, if the preset capability mask field is zero, the configuration module is executed directly. If the preset capability mask field is non-zero, determine whether the capability bit set in the global capability structure contains all the capability bits required by the preset capability mask field; If not, the parsing, validation, and application callback operations of the configuration module will be skipped, and no error log will be generated.

[0010] In one possible implementation, the preset byte position of the sub-board serial number is the 12th byte, and the dynamically extended sub-board is a GPS positioning sub-board.

[0011] In a second aspect of this application, an embedded device hardware capability detection apparatus is provided, the apparatus comprising: The static mapping table query module is used to query the corresponding static mapping table based on the device identifier of the embedded device during the startup phase of the embedded device to obtain the basic capability bit set. The static mapping table records the in-situ status of each preset fixed hardware module. The dynamic expansion sub-board determination module is used to obtain the sub-board serial number of the embedded device, determine the dynamic expansion sub-board presence status represented by the byte value of the sub-board serial number at a preset byte position, and obtain the dynamic expansion capability bit set; wherein, the byte value of the sub-board serial number at the preset byte position is preset during the manufacturing of the embedded device; The capability bit parsing and judgment module is used to obtain the current number of instances of hardware resources, and write the number of instances, the basic capability bit set, and the dynamically extended capability bit set into the global capability structure. This allows the parsing, verification, and application callback operations of the configuration module to be skipped when the capability bit set in the global capability structure does not contain all the capability bits required by the preset capability mask field corresponding to the configuration module during the configuration module execution phase.

[0012] In one possible implementation, the dynamic expansion subboard determination module includes: The sub-board serial number reading sub-module is specifically used to read the sub-board serial number of the embedded device. In the event of a reading failure, the bit in the dynamic expansion capability bits that represents the in-bit state of the dynamic expansion sub-board is set to 0. The byte value judgment submodule is specifically used to determine, upon successful reading, whether the byte value of the subboard serial number at the preset byte position indicates that the dynamic expansion subboard is in place; if yes, then set the bit representing the dynamic expansion capability state of the dynamic expansion subboard to 1; if no, then set the bit representing the dynamic expansion capability state of the dynamic expansion subboard to 0.

[0013] In one possible implementation, the capability bit parsing and determination module specifically includes: The bitwise AND operation submodule is specifically used to perform a bitwise AND operation on the set of capability bits in the global capability structure and the preset capability mask field corresponding to the configuration module. The result judgment submodule is specifically used to determine that if the result of the bitwise AND operation is not equal to the preset capability mask field, the capability bit set does not contain all the capability bits required by the preset capability mask field, and the parsing, verification and application callback operations of the configuration module are skipped.

[0014] In one possible implementation, the device further includes: A preset test environment variable detection module is used to detect whether preset test environment variables exist; wherein, the preset test environment variables include capability bits of each configuration module; if they exist, the value of the preset test environment variables is written into the global capability structure.

[0015] In one possible implementation, the dynamic expansion subboard determination module includes: The byte value determination submodule is specifically used to determine that the presence status of the dynamic expansion subboard is not present when the byte value of the subboard serial number at the preset byte position is 0; and to determine that the presence status of the dynamic expansion subboard is present when the byte value of the subboard serial number at the preset byte position is non-zero, and to determine the type of the dynamic expansion subboard based on the byte value; wherein, different byte values ​​correspond to different types of dynamic expansion subboards.

[0016] In one possible implementation, the capability bit parsing and judgment module is specifically used for: During the configuration module execution phase, for each configuration module, if the preset capability mask field is zero, the configuration module is executed directly. If the preset capability mask field is non-zero, determine whether the capability bit set in the global capability structure contains all the capability bits required by the preset capability mask field; If not, the parsing, validation, and application callback operations of the configuration module will be skipped, and no error log will be generated.

[0017] In one possible implementation, the preset byte position of the sub-board serial number is the 12th byte, and the dynamically extended sub-board is a GPS positioning sub-board.

[0018] In a third aspect of this application, an electronic device is provided, comprising: Memory, used to store computer programs; When a processor executes a program stored in memory, it implements the method described in the first aspect of the embodiments of this application.

[0019] In a fourth aspect of the present application, a computer-readable storage medium is provided, wherein a computer program is stored therein, and the computer program, when executed by a processor, implements the method described in the first aspect of the present application.

[0020] Compared with the prior art, the embodiments of this application have at least the following technical effects: This application provides an embedded device hardware capability detection method, apparatus, electronic device, and medium. During the embedded device startup phase, a basic capability bit set is obtained by querying a corresponding static mapping table based on the embedded device's device identifier. The static mapping table records the presence status of each preset fixed hardware module. The sub-board serial number of the embedded device is obtained, and the presence status of the dynamically extended sub-board represented by the byte value of the sub-board serial number at a preset byte position is determined to obtain a dynamically extended capability bit set. The byte value of the sub-board serial number at the preset byte position is pre-set during the embedded device's production. The current instance count of hardware resources is obtained, and the instance count, the basic capability bit set, and the dynamically extended capability bit set are written into a global capability structure. This ensures that during the configuration module execution phase, for each configuration module, if the capability bit set in the global capability structure does not contain all the capability bits required by the preset capability mask field corresponding to the configuration module, the parsing, verification, and application callback operations of that configuration module are skipped.

[0021] By applying the method of this application embodiment, and utilizing the existing daughterboard SN encoding standard on the factory production line, the byte value representing the in-situ status of the dynamically expanded daughterboard is burned into the daughterboard serial number during device production. This eliminates the need for any additional processes, configuration files, or communication interactions, allowing for accurate identification of the dynamically expanded daughterboard's in-situ status at runtime. This reduces the detection cost of the device's dynamically expanded daughterboard capabilities, eliminates the need for additional external file maintenance, thereby reducing the possibility of hardware capability detection failures and improving hardware capability detection efficiency. Furthermore, the capability detection method of this application is performed during the embedded device startup phase, ensuring the capability set remains stable and available throughout the entire process lifecycle. This avoids capability gaps that occur during cloud interaction, further improving hardware capability detection efficiency.

[0022] In addition, during the configuration execution phase, by determining whether the set of capability bits in the global capability structure contains all the capability bits required by the preset capability mask field corresponding to the configuration module, it is ensured that inapplicable configuration modules (such as the GPS module when there is no GPS daughterboard, and the SERIAL_2 module when there is no second serial port) are accurately masked, thereby eliminating errors caused by the absence of hardware resources when executing the configuration module callback operation and improving the success rate of device configuration.

[0023] Of course, implementing any method of the embodiments of this application does not necessarily require achieving all of the advantages described above at the same time. Attached Figure Description

[0024] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings.

[0025] Figure 1 A flowchart of an embedded device hardware capability detection method provided in an embodiment of this application; Figure 2 A flowchart illustrating the location of dynamic expansion capabilities provided in this application embodiment; Figure 3 Another flowchart of the embedded device hardware capability detection method provided in the embodiments of this application; Figure 4 A schematic diagram of an embedded device hardware capability detection device provided in an embodiment of this application; Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0026] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art based on this application are within the scope of protection of this application.

[0027] To facilitate understanding of this application, the following explanations are provided for any technical terms that may appear in this application: Sonboardsn: Son Board Serial Number, a unique identifier string burned into the daughter board's EEPROM at the factory; capability_mask: Configures the capability mask of the module, identifying which hardware capabilities the module requires to execute; Pass2: The second scan stage of DM Profile processing, responsible for applying the configuration to the device system; Ubus: OpenWrt Unified Bus, a device-local inter-process communication framework; CAP_GPS: GPS positioning subboard capability flag, value is (1<<7), i.e. 0x80; base_caps: The set of basic fixed hardware capabilities corresponding to the product model, excluding optional sub-boards; ZTP: Zero-Touch Provisioning, an automatic device registration and configuration process that requires no manual intervention; DM Profile: Device Management Profile, a device management configuration document issued by the cloud platform; yruo_info: Device information ubus object, providing interfaces for querying hardware identifiers such as sonboardsn; yruo_cell: A cellular module ubus object that provides an interface for querying cellular-related information such as the number of SIM cards.

[0028] In related technologies, the following approaches can be used to detect and configure the capabilities of configuration modules: Option 1: Identify hardware characteristics by reading the independent capability description file (such as / etc / hw_caps.conf) written by the factory.

[0029] The drawbacks of this solution are: the files need to be maintained separately, which poses a risk of version drift with the actual hardware; an additional burning process is required during mass production of the device, resulting in a yield loss of about 0.3%; and there is no downgrade strategy after the files are damaged, leading to the failure of all capability assessments.

[0030] Option 2: The cloud platform issues a list of capabilities during device registration, which the device then caches and uses.

[0031] The drawbacks of this solution are: there is a capability gap between the device cold start and the establishment of the cloud connection (usually 30-120 seconds), during which locally triggered configuration operations cannot be properly filtered; when the network is interrupted, the capability cache may expire, causing erroneous behavior.

[0032] Option 3: Enumerate all capability combinations in the code by product model (SKU).

[0033] The drawback of this solution is that there are variants of the same model that can be equipped with daughter boards (such as GPS daughter boards). Different batches of shipments have the same SKU string but different hardware, which leads to about 5%-15% of device capability judgment errors. Adding a new daughter board variant requires modifying the code and re-releasing the firmware.

[0034] Option 4: Identify the daughterboard's presence status by reading specific GPIO levels or hardware register flags.

[0035] The drawbacks of this solution are: it requires adding dedicated pin definitions to the BSP layer, resulting in high porting costs; the driver needs to be modified synchronously after hardware design changes; and the detection results are unstable when the device is powered on but the daughterboard has not completed initialization.

[0036] Option 5: Require maintenance personnel to manually declare the hardware configuration via a web interface or CLI when the device is first deployed.

[0037] The drawbacks of this solution are: extremely high labor costs when deploying on a large scale (thousands of units); difficulty in tracing configuration errors afterward; and complete impracticality in zero-touch network configuration (ZTP) scenarios.

[0038] To address at least one of the aforementioned problems, a first aspect of this application provides a method for detecting the hardware capabilities of an embedded device, the method comprising: Figure 1 The steps shown are as follows: Step S101: During the embedded device startup phase, query the corresponding static mapping table based on the embedded device's device identifier to obtain the basic capability bit set.

[0039] Pre-defined fixed hardware modules refer to key hardware components that are physically integrated into an embedded device at the factory and cannot be changed, forming the core functionality of the embedded device. In one example, pre-defined fixed hardware modules may include at least one or more of the following: a cellular module, a WiFi (Wireless Local Area Network) module, a LoRa (Long Range Radio) module, serial port 1, serial port 2, two digital inputs, and two digital outputs. In practical applications, different product models of embedded products may have the same or different fixed basic hardware configurations, which are defined through a static mapping table. The static mapping table records the in-situ status of each pre-defined fixed hardware module.

[0040] By using the device identifier of the embedded device, the static mapping table corresponding to the embedded device can be obtained. Querying this static mapping table reveals the presence status of each preset fixed hardware module of the embedded device, resulting in a set of basic capability bits. The basic capability bits indicate whether the embedded device possesses the capability corresponding to the preset fixed hardware module. When the presence status of the preset fixed hardware module indicates that it is present, the embedded device is considered to possess its corresponding capability.

[0041] Step S102: Obtain the daughterboard serial number of the embedded device, determine the dynamic expansion daughterboard presence status represented by the byte value at the preset byte position of the daughterboard serial number, and obtain the dynamic expansion capability bit set.

[0042] Among them, the dynamic expansion daughterboard is a hardware expansion module that can be recognized by the system and dynamically loaded with its functions through an interface during device operation. In one example, the dynamic expansion daughterboard can be a GPS (Global Positioning System) positioning daughterboard.

[0043] The byte value of the sonboard serial number at the preset byte position is pre-set during embedded device manufacturing. The sonboard serial number (sonboardsn) is a unique identifier string burned into the sonboard's EEPROM (Electrically Erasable Programmable Read-Only Memory) by the factory during embedded device production. The preset byte position can be set according to actual application requirements, such as the 12th byte (index 11, counting from 0), 13th byte, etc., of the sonboard serial number. The byte value at this preset byte position can use different characters to represent the presence status of the dynamically expandable sonboard through factory coding conventions. For example, when the byte value of the sonboard serial number at the preset byte position is "0", it is considered that the dynamically expandable sonboard is not present, and the embedded device does not have the function of dynamically expanding the sonboard. Within the dynamic expansion capability bit set, the dynamic expansion capability bit indicates whether the embedded device has the capability corresponding to the dynamically expandable sonboard.

[0044] In one possible implementation, different byte values ​​can be set to represent different types of dynamic expansion daughterboards, as shown in the following steps: Step A: When the byte value of the sub-board serial number at the preset byte position is 0, the presence status of the dynamic expansion sub-board is determined to be absent.

[0045] Step B: When the byte value of the sub-board serial number at the preset byte position is non-zero, determine that the dynamic expansion sub-board is in place, and determine the type of the dynamic expansion sub-board according to the byte value; wherein, different byte values ​​correspond to different types of dynamic expansion sub-boards.

[0046] In one example, the dynamic expansion subboard is a positioning function subboard, which includes a GPS positioning subboard and a high-precision GNSS positioning subboard. "0" indicates that the embedded device does not have a dynamic expansion subboard; "G" indicates that the dynamic expansion subboard is a GPS positioning subboard; and "N" indicates that the dynamic expansion subboard is a GNSS (Global Navigation Satellite System) positioning subboard.

[0047] In one possible implementation, step S102 can be achieved through the following steps: Step 1: Read the serial number of the embedded device's daughterboard. If the reading fails, set the bit representing the dynamic expansion capability state of the daughterboard to 0.

[0048] Step 2: If the reading is successful, determine whether the byte value of the sub-board serial number at the preset byte position indicates that the dynamically extended sub-board is in place.

[0049] If yes, proceed to step three; otherwise, proceed to step four. Step 3: Set the bit representing the state of the dynamic expansion subboard in the dynamic expansion capability bits to 1.

[0050] Step 4: Set the bit representing the state of the dynamic expansion subboard in the dynamic expansion capability bits to 0.

[0051] In one example, such as Figure 2 As shown, when the dynamically extended subboard is a GPS positioning subboard, the capability_probe (local probe function) is first called to read the subboard serial number. If the reading fails, GetFailed is returned to indicate that the subboard serial number reading failed. A conservative strategy is adopted, and the bit representing the dynamic extended subboard's status in the dynamic extended capability bits is set to 0 to obtain CapGPS_Clear (GPS capability clear status). This is then merged with base_caps to obtain the merge result (mergeresult), which is written into the global capability structure.

[0052] If the daughterboard serial number is successfully read, a byte check is performed to determine if the byte value at the preset byte position indicates that the dynamic expansion daughterboard is in place. If so, GPS_Present is returned, indicating that the dynamic expansion daughterboard is in place. The bit representing the presence of the dynamic expansion capability is set to 1 (e.g., the 7th bit is set to 1), resulting in CapGPS_Set. This is then merged with base_caps to obtain the merged result (mergeresult), which is written into the global capability structure. If not, GPS_Absent is returned, indicating that the dynamic expansion daughterboard is not in place. The bit representing the presence of the dynamic expansion capability is set to 0, resulting in CapGPS_Clear. This is then merged with base_caps to obtain the merged result (mergeresult), which is written into the global capability structure.

[0053] Step S103: Obtain the current number of hardware resource instances, and write the number of instances, the basic capability bit set, and the dynamic extended capability bit set into the global capability structure. This will ensure that during the configuration module execution phase, for each configuration module, if the capability bit set in the global capability structure does not contain all the capability bits required by the preset capability mask field corresponding to the configuration module, the parsing, verification, and application callback operations of that configuration module will be skipped.

[0054] In this application, the instance count refers to the number of SIM cards, which can be obtained by calling system services through the local inter-process communication interface. After obtaining the instance count, it can be written into a separate quantity field of the global capability structure. The number of SIM cards is stored as a separate integer field, does not occupy bits of the capability bits, and can be dynamically obtained through ubus (system bus).

[0055] The global capability structure includes both a basic set of capability bits and a dynamically extended set of capability bits, which can simultaneously represent all the capabilities currently possessed by the embedded device. In one example, the capability bits in this embodiment can be defined as shown in Table 1 below: Table 1

[0056] In one possible implementation, during the configuration module execution phase, the module's capabilities can be probed through the following steps: Step 1: Perform a bitwise AND operation between the set of capability bits in the global capability structure and the preset capability mask field corresponding to the configuration module.

[0057] Step 2: If the result of the bitwise AND operation is not equal to the preset capability mask field, it is determined that the capability bit set does not contain all the capability bits required by the preset capability mask field, and the parsing, verification and application callback operations of the configuration module are skipped.

[0058] The preset capability mask field indicates the capabilities required by the embedded device. In one example, the preset capability mask field can be set according to Table 2 below: Table 2

[0059] In one example, for an embedded device UR35 (product ID=35), its installed dynamic expansion daughterboard is a GPS positioning daughterboard. The factory-written sonboardsn is "SN202404G1A001", and the 12th byte (index 11) is the character 'G', which is not equal to '0', indicating that the GPS positioning daughterboard is in place. The probe_gps_from_sonboardsn() function (used to detect and activate the GPS module based on the daughterboard serial number) performs a bitwise OR operation between CAP_GPS (0x80) and base_caps (0x77), ultimately obtaining g_capability.caps (global capability set) = 0xF7. The GPS configuration module's capability_mask (preset capability mask field) = CAP_GPS. The bitwise AND result of g_caps (global capability set) and capability_mask is calculated, and it is determined whether the bitwise AND result is the same as the preset capability mask field. If they are the same, it is determined that the capability bit set contains all the capability bits required by the preset capability mask field.

[0060] If `capability_has` (a function used to determine whether a certain capability is possessed) returns true, it indicates that the capability bit set contains all capability bits required by the preset capability mask field, and the module normally executes `parse / check / apply` (configuration parsing / availability verification / registration activation), and the GPS coordinate reporting function is enabled. In one possible implementation, before the embedded device startup phase, the method further includes: Check if preset test environment variables exist; wherein, the preset test environment variables include the capability bits of each configuration module; If it exists, write the value of the preset test environment variable into the global capability structure.

[0061] In a continuous integration environment, a complete capability set can be injected through the environment variable TEST_FAKE_CAPABILITY=0xFF. Before the embedded device startup phase, capability_probe() checks whether the preset test environment variable exists. If it exists, the injected value is written directly and returned, skipping the hardware detection in steps S101-S103. This allows test cases to cover the parse / check / apply paths of all configuration modules without physical hardware, achieving 100% module test coverage.

[0062] By applying the method of the embodiments of this application, the TEST_FAKE_CAPABILITY environment variable injection mechanism allows for the precise injection of any combination of capabilities in a CI (Continuous Integration) environment without physical hardware, so that the code paths of all configuration modules can be covered by automated tests, making the test environment completely controllable.

[0063] In another possible implementation, the configuration execution of step S103 can also be achieved through the following steps: During the configuration module execution phase, for each configuration module, if the preset capability mask field is zero, the configuration module is executed directly. If the preset capability mask field is non-zero, determine whether the capability bit set in the global capability structure contains all the capability bits required by the preset capability mask field; If not, the parsing, validation, and application callback operations of the configuration module will be skipped, and no error log will be generated.

[0064] In practical applications, configuration modules with a preset capability mask field of zero can be executed directly without capability checks, indicating that the module is applicable to all product models; configuration modules with a preset capability mask field of non-zero are executed only when the device capability bit set contains all the capability bits required by the preset capability mask field. Skipping the parsing, verification and application callback operations of this configuration module is a silent skip and does not generate error log output, thereby avoiding misleading alarm information in normal operating scenarios.

[0065] In one example, such as Figure 3 The diagram illustrates the hardware capability detection process of this application. First, the process starts and calls `capability_probe()` to determine if the preset test environment variables exist. If they exist, the injected values ​​(injected test capability set) are directly written into the global capability structure. If they do not exist, the basic capability bit set is obtained by querying the static mapping table. The presence status of the dynamically extended sub-board, represented by the byte value of the sub-board serial number at the preset byte position, is determined to obtain the dynamically extended capability bit set. The current instance count of the hardware resource is obtained, and the instance count, the basic capability bit set, and the dynamically extended capability bit set are written into the global capability structure.

[0066] When the DM Profile (Device Management Profile) is issued on the cloud platform, the PASS2 stage is executed. It is determined whether the preset capability mask field is zero. If it is, the configuration module is executed directly. If not, it is determined whether the capability bit set in the global capability structure contains all the capability bits required by the preset capability mask field. If it is, the configuration module is executed. Otherwise, the parsing, verification and application callback operations of the configuration module are silently skipped.

[0067] In one possible implementation, for scenarios that require simultaneous detection of multiple subboards, the combined encoding of multiple predefined byte bits in the subboard SN can be used to complete the determination of multiple capabilities in one read, avoiding the performance overhead of multiple ubus calls.

[0068] By applying the method of this application embodiment, and utilizing the existing daughterboard SN encoding standard on the factory production line, the byte value representing the in-situ status of the dynamically expanded daughterboard is burned into the daughterboard serial number during device production. This eliminates the need for any additional processes, configuration files, or communication interactions, allowing for accurate identification of the dynamically expanded daughterboard's in-situ status at runtime. This reduces the detection cost of the device's dynamically expanded daughterboard capabilities, eliminates the need for additional external file maintenance, thereby reducing the possibility of hardware capability detection failures and improving hardware capability detection efficiency. Furthermore, the capability detection method of this application is performed during the embedded device startup phase, ensuring the capability set remains stable and available throughout the entire process lifecycle. This avoids capability gaps that occur during cloud interaction, further improving hardware capability detection efficiency.

[0069] In addition, during the configuration execution phase, by determining whether the set of capability bits in the global capability structure contains all the capability bits required by the preset capability mask field corresponding to the configuration module, it is ensured that inapplicable configuration modules (such as the GPS module when there is no GPS daughterboard, and the SERIAL_2 module when there is no second serial port) are accurately masked, thereby eliminating errors caused by the absence of hardware resources when executing the configuration module callback operation and improving the success rate of device configuration.

[0070] Secondly, in this embodiment, when adding a new daughterboard variant, the factory only needs to write a non-zero identifier in the corresponding byte of the SN, and the software can automatically recognize the new capability without modification. For scenarios that require supporting multiple daughterboard configurations under the same product model, the expansion cost approaches zero.

[0071] Furthermore, the method in this application embodiment relies only on the SN (Serial Number) string built into the device (obtained through any local IPC (Inter-Process Communication) mechanism), does not depend on a specific hardware platform or operating system interface, and can be directly ported to any embedded platform with an embedded daughterboard SN, such as industrial gateways, base stations, and edge computing devices, resulting in low promotion costs.

[0072] In a second aspect of this application, an embedded device hardware capability detection device is provided, the device comprising: Figure 4 The structure shown is as follows: The static mapping table query module 401 is used to query the corresponding static mapping table based on the device identifier of the embedded device during the startup phase of the embedded device to obtain the basic capability bit set. The static mapping table records the in-situ status of each preset fixed hardware module.

[0073] The dynamic expansion sub-board determination module 402 is used to obtain the sub-board serial number of the embedded device, determine the dynamic expansion sub-board presence status represented by the byte value of the sub-board serial number at a preset byte position, and obtain a dynamic expansion capability bit set; wherein, the byte value of the sub-board serial number at the preset byte position is preset during the manufacturing of the embedded device.

[0074] The capability bit parsing and judgment module 403 is used to obtain the current number of instances of hardware resources and write the number of instances, the basic capability bit set, and the dynamically extended capability bit set into a global capability structure. This is so that during the configuration module execution phase, for each configuration module, if the capability bit set in the global capability structure does not contain all the capability bits required by the preset capability mask field corresponding to the configuration module, the parsing, verification, and application callback operations of that configuration module are skipped.

[0075] In one possible implementation, the dynamic expansion subboard determination module includes: The sub-board serial number reading sub-module is specifically used to read the sub-board serial number of the embedded device. In the event of a reading failure, the bit in the dynamic expansion capability bits that represents the in-bit state of the dynamic expansion sub-board is set to 0. The byte value judgment submodule is specifically used to determine, upon successful reading, whether the byte value of the subboard serial number at the preset byte position indicates that the dynamic expansion subboard is in place; if yes, then set the bit representing the dynamic expansion capability state of the dynamic expansion subboard to 1; if no, then set the bit representing the dynamic expansion capability state of the dynamic expansion subboard to 0.

[0076] In one possible implementation, the capability bit parsing and determination module specifically includes: The bitwise AND operation submodule is specifically used to perform a bitwise AND operation on the set of capability bits in the global capability structure and the preset capability mask field corresponding to the configuration module. The result judgment submodule is specifically used to determine that if the result of the bitwise AND operation is not equal to the preset capability mask field, the capability bit set does not contain all the capability bits required by the preset capability mask field, and the parsing, verification and application callback operations of the configuration module are skipped.

[0077] In one possible implementation, the device further includes: A preset test environment variable detection module is used to detect whether preset test environment variables exist; wherein, the preset test environment variables include capability bits of each configuration module; if they exist, the value of the preset test environment variables is written into the global capability structure.

[0078] In one possible implementation, the dynamic expansion subboard determination module includes: The byte value determination submodule is specifically used to determine that the presence status of the dynamic expansion subboard is not present when the byte value of the subboard serial number at the preset byte position is 0; and to determine that the presence status of the dynamic expansion subboard is present when the byte value of the subboard serial number at the preset byte position is non-zero, and to determine the type of the dynamic expansion subboard based on the byte value; wherein, different byte values ​​correspond to different types of dynamic expansion subboards.

[0079] In one possible implementation, the capability bit parsing and judgment module is specifically used for: During the configuration module execution phase, for each configuration module, if the preset capability mask field is zero, the configuration module is executed directly. If the preset capability mask field is non-zero, determine whether the capability bit set in the global capability structure contains all the capability bits required by the preset capability mask field; If not, the parsing, validation, and application callback operations of the configuration module will be skipped, and no error log will be generated.

[0080] In one possible implementation, the preset byte position of the sub-board serial number is the 12th byte, and the dynamically extended sub-board is a GPS positioning sub-board.

[0081] In a third aspect of the embodiments of this application, an electronic device is provided, see [link to relevant documentation]. Figure 5 ,include: Memory 501 is used to store computer programs; Processor 502, when executing a program stored in memory, implements: During the startup phase of the embedded device, the corresponding static mapping table is queried according to the device identifier of the embedded device to obtain the basic capability bit set. The static mapping table records the in-situ status of each preset fixed hardware module. Obtain the daughterboard serial number of the embedded device, determine the dynamic expansion daughterboard presence status represented by the byte value of the daughterboard serial number at a preset byte position, and obtain the dynamic expansion capability bit set; wherein, the byte value of the daughterboard serial number at the preset byte position is preset during the manufacturing of the embedded device; Obtain the current number of hardware resource instances, and write the number of instances, the basic capability bit set, and the dynamic extended capability bit set into a global capability structure. This ensures that during the configuration module execution phase, for each configuration module, if the capability bit set in the global capability structure does not contain all the capability bits required by the preset capability mask field corresponding to the configuration module, the parsing, verification, and application callback operations of that configuration module are skipped.

[0082] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.

[0083] The communication interface is used for communication between the aforementioned electronic devices and other devices.

[0084] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0085] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0086] In a fourth aspect of the embodiments of this application, a computer-readable storage medium is provided, wherein a computer program is stored therein, and when the computer program is executed by a processor, it implements the method of the first aspect of the embodiments of this application.

[0087] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to implement the method of the first aspect of the embodiments of this application.

[0088] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a solid-state drive (SSD), etc.

[0089] 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, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0090] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. Related parts can be found in the descriptions of the system embodiments.

[0091] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application are included within the scope of protection of this application.

Claims

1. A method for detecting the hardware capabilities of an embedded device, characterized in that, The method includes: During the startup phase of the embedded device, the corresponding static mapping table is queried according to the device identifier of the embedded device to obtain the basic capability bit set. The static mapping table records the in-situ status of each preset fixed hardware module. Obtain the daughterboard serial number of the embedded device, determine the dynamic expansion daughterboard presence status represented by the byte value of the daughterboard serial number at a preset byte position, and obtain the dynamic expansion capability bit set; wherein, the byte value of the daughterboard serial number at the preset byte position is preset during the manufacturing of the embedded device; Obtain the current number of hardware resource instances, and write the number of instances, the basic capability bit set, and the dynamic extended capability bit set into a global capability structure. This ensures that during the configuration module execution phase, for each configuration module, if the capability bit set in the global capability structure does not contain all the capability bits required by the preset capability mask field corresponding to the configuration module, the parsing, verification, and application callback operations of that configuration module are skipped.

2. The method according to claim 1, characterized in that, The step of obtaining the sub-board serial number of the embedded device, determining the dynamic expansion sub-board presence status represented by the byte value of the sub-board serial number at a preset byte position, and obtaining the dynamic expansion capability bit set includes: Read the serial number of the embedded device's sub-board. If the reading fails, set the bit in the dynamic expansion capability bits that represents the state of the dynamic expansion sub-board to 0. If the read is successful, determine whether the byte value of the sub-board serial number at the preset byte position indicates that the dynamically extended sub-board is in place; If so, set the bit representing the in-bit state of the dynamic expansion capability bit to 1; If not, then set the bit representing the in-bit state of the dynamic expansion capability bit to 0.

3. The method according to claim 1, characterized in that, When the set of capability bits in the global capability structure does not contain all the capability bits required by the preset capability mask field corresponding to the configuration module, the parsing, verification, and application callback operations of the configuration module are skipped, including: Perform a bitwise AND operation between the set of capability bits in the global capability structure and the preset capability mask field corresponding to the configuration module; If the result of the bitwise AND operation is not equal to the preset capability mask field, it is determined that the capability bit set does not contain all the capability bits required by the preset capability mask field, and the parsing, verification and application callback operations of the configuration module are skipped.

4. The method according to claim 1, characterized in that, Prior to the embedded device startup phase, the method further includes: Check if preset test environment variables exist; wherein, the preset test environment variables include the capability bits of each configuration module; If it exists, write the value of the preset test environment variable into the global capability structure.

5. The method according to claim 1, characterized in that, The step of determining the presence status of the dynamically extended subboard, represented by the byte value of the subboard serial number at a preset byte position, includes: When the byte value of the sub-board serial number at the preset byte position is 0, the presence status of the dynamic expansion sub-board is determined to be absent. When the byte value of the sub-board serial number at the preset byte position is non-zero, the in-situ state of the dynamic expansion sub-board is determined to be in-situ, and the type of the dynamic expansion sub-board is determined according to the byte value; wherein, different byte values ​​correspond to different types of dynamic expansion sub-boards.

6. The method according to claim 1, characterized in that, During the configuration module execution phase, for each configuration module, if the set of capability bits in the global capability structure does not contain all the capability bits required by the preset capability mask field corresponding to the configuration module, the parsing, verification, and application callback operations of that configuration module are skipped, including: During the configuration module execution phase, for each configuration module, if the preset capability mask field is zero, the configuration module is executed directly. If the preset capability mask field is non-zero, determine whether the capability bit set in the global capability structure contains all the capability bits required by the preset capability mask field; If not, the parsing, validation, and application callback operations of the configuration module will be skipped, and no error log will be generated.

7. The method according to claim 1, characterized in that, The preset byte position of the sub-board serial number is the 12th byte, and the dynamic expansion sub-board is a GPS positioning sub-board.

8. An embedded device hardware capability detection device, characterized in that, The device includes: The static mapping table query module is used to query the corresponding static mapping table based on the device identifier of the embedded device during the startup phase of the embedded device to obtain the basic capability bit set. The static mapping table records the in-situ status of each preset fixed hardware module. The dynamic expansion sub-board determination module is used to obtain the sub-board serial number of the embedded device, determine the dynamic expansion sub-board presence status represented by the byte value of the sub-board serial number at a preset byte position, and obtain the dynamic expansion capability bit set; wherein, the byte value of the sub-board serial number at the preset byte position is preset during the manufacturing of the embedded device; The capability bit parsing and judgment module is used to obtain the current number of instances of hardware resources, and write the number of instances, the basic capability bit set, and the dynamically extended capability bit set into the global capability structure. This allows the parsing, verification, and application callback operations of the configuration module to be skipped when the capability bit set in the global capability structure does not contain all the capability bits required by the preset capability mask field corresponding to the configuration module during the configuration module execution phase.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the method described in claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium contains a computer program that, when executed by a processor, implements the method described in claims 1-7.