Log level setting device of intelligent equipment
Through the log level setting device of the intelligent device, the log printing level of the intelligent module is refined by using various communication methods, which solves the problem of single and inflexible log level adjustment in the existing technology, and improves information security and operation efficiency.
Patent Information
- Application Number
- CN202411476322.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2025-01-10
AI Technical Summary
The application scenarios and methods for the log level adjustment of existing intelligent modules are relatively single, resulting in insufficient flexibility in log printing level management, affecting information security and operation efficiency.
Design a log level setting device for intelligent devices, and connects the communication between external devices to the intelligent module and the entire machine device, and uses commands to represent the function module with high 16-bit data and low 16-bit data to represent the log level, supporting serial port, Various settings of UDP communication and cloud interfaces enable refined control of the log printing level of smart modules.
It improves the flexibility and efficiency of log management, meets the log level setting requirements for different application scenarios, and enhances the functional use and troubleshooting capabilities of smart devices.
Smart Images

Figure CN119292544A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of smart home appliances, and in particular to a device for setting the log level of a smart device. Background Art
[0002] The smart modules carried by smart products need to be analyzed and debugged according to the different levels of module printing logs during product development and testing. At present, the level management of module printing logs is relatively extensive, and there are too many default open printing log contents. On the one hand, there are certain information security issues after the product leaves the factory, and on the other hand, too much log printing will reduce the operating efficiency of the smart module, thereby affecting the functional use of the product. Therefore, the printing specification of smart modules needs to be highly valued by manufacturers.
[0003] Among the existing patents, patent document CN202410563690.5 (dynamic adjustment method, device, system and computer program product for log level) provides a method, device, system and computer program product for dynamic adjustment of log level. In the vehicle-mounted AUTOSAR AP system, this method can realize dynamic adjustment of log level without restarting the application program. The log level of the application program can be adjusted at any time according to the scene requirements, which is simple and convenient. However, the application scenario and adjustment method of the log level adjustment described in the invention are relatively simple. Summary of the invention
[0004] In order to solve the problem that the application scenarios and adjustment methods of log level adjustment are relatively single, the present application provides a log level setting device for an intelligent device, including: an external device, an intelligent module and a complete device, the external device is communicatively connected to the intelligent module, and the intelligent module is communicatively connected to the complete device.
[0005] The smart module includes a plurality of functional modules, and each of the functional modules is configured to record functional logs according to log levels.
[0006] The external device is configured to: issue a log printing command to the smart module, the log printing command including high sixteen-bit data and low sixteen-bit data, the high sixteen-bit data is used to represent the functional module to be printed, and the low sixteen-bit data is used to represent the log level to be printed.
[0007] The smart module is configured to: receive the log printing command, and print the function log according to the log printing command.
[0008] In a feasible implementation, there are a total of sixteen functional modules, and the functional modules include at least: module basic information module, serial port data transceiver module, WiFi network configuration module, HTTP interface access module, MQTT message transceiver module, big data reporting module, Bluetooth function module, firmware upgrade module, remote diagnosis module, key update module, voice recognition broadcast module, production test command module, third-party platform module and automated test interface module.
[0009] In a feasible implementation, the log levels include: NOTICE, DEBUG, WARN, ERROR, and FATAL.
[0010] In a feasible implementation, the external device is further configured to: connect to the smart module according to the connection status between the smart module and the whole device, using a communication connection method corresponding to the connection status.
[0011] In a feasible implementation, the step of the external device connecting to the smart module in a communication connection mode corresponding to the connection state according to the connection state between the smart module and the whole device includes:
[0012] Determine the connection status between the smart module and the whole device, where the connection status includes a connected state and a disconnected state.
[0013] When the smart module and the whole device are in a disconnected state, the external device is connected to the smart module via serial port communication and sets the log level.
[0014] When the smart module and the whole device are in a disconnected state, it is determined whether the whole device enters a user mode.
[0015] When the whole device enters the user mode, the external device connects to the smart module through UDP communication on the same local area network and sets the log level.
[0016] When the whole device does not enter the user mode, it is determined whether the whole device has completed network configuration.
[0017] When the whole device completes the network configuration, the external device cloud interface remotely connects to the smart module and sets the log level.
[0018] When the network configuration of the whole device is not completed, the external device connects to the smart module through UDP communication in a point-to-point manner and sets the log level.
[0019] In a feasible implementation, the smart module is further configured to: obtain high-order sixteen-bit data in the log printing command from the log printing command, and determine whether any one or more bits in the high-order sixteen-bit data are 1.
[0020] When one or more bits in the high 16-bit data are 1, the intelligent module selects the functional module according to the number of bits that are 1, and prints a log for the selected functional module.
[0021] In a feasible implementation, the smart module is further configured to: obtain the lower sixteen bits of data in the log printing command from the log printing command, and determine whether any one or more bits in the lower sixteen bits of data are 1.
[0022] When one or more bits in the lower sixteen bits of the data are 1, the intelligent module selects the log level according to the number of bits that are 1, and prints out the selected functional module according to the selected log level.
[0023] The present application provides a log level setting device for an intelligent device. The intelligent module log printing level is stored in 32-bit data, wherein the upper 16 bits store the function module information, and the lower 16 bits store the log level information. The function module information and the log level information jointly constrain the printing level, making the overall module log printing level setting more flexible and accurate. In addition, in addition to the existing serial communication setting method, the log printing level setting method also adds a UDP communication setting method and a remote setting method for online devices through a cloud interface. Different setting methods meet the log level setting requirements of the intelligent module in different application scenarios, and the usage scenarios are more flexible. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The accompanying drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the implementation of the present invention, and together with the specification are used to explain the principles of the embodiments of the present invention. Obviously, the accompanying drawings described below are only some embodiments of the implementation of the present invention, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0025] Figure 1 It is a structural diagram of a log level setting device for a smart device according to an embodiment of the present application;
[0026] Figure 2 It is a schematic diagram of the setting method of the log printing level of the smart module in different scenarios according to the embodiment of the present application;
[0027] Figure 3 It is a flow chart of connecting an external device to a smart module according to an embodiment of the present application. DETAILED DESCRIPTION
[0028] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the embodiments of the present invention will be more comprehensive and complete and fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, many specific details are provided to provide a full understanding of the implementation of the embodiments of the present invention.
[0029] The smart modules configured in existing smart devices are divided into multiple functional modules. Each functional module runs in a different thread, which is both independent and cooperative to ensure the normal operation of the entire system. When the module program runs to different stages, its log output printing should be different. When the product test needs to verify the content of the big data report, only the log output and the printing information related to the big data report are needed. Other printing information will interfere with the current test and need to be turned off. Therefore, it is necessary to set the module's log printing level to ensure that the test of the big data reporting function can proceed normally.
[0030] The existing smart module log printing level setting specification and setting method generally divide the smart module log level into 16 levels, where level 0 indicates the least number of printed logs, and level 15 indicates the most and most complete number of printed logs. The log levels are represented by 0x00 to 0x0F from the lowest to the highest. For example, when the log level value is 0x03, the smart module print log contains log information of level 0, level 1, level 2, and level 3. This printing method is not divided according to the specific functional modules of the smart module, but is roughly divided according to experience and large functional modules. When a certain printing level value is set, all printing levels below this value will be printed, and the printing results cannot be accurately given according to the relevant functional modules in the relevant instructions 1.
[0031] In addition, the setting of the smart module printing level is carried out through the serial communication between the external device and the smart module. The communication data contains the printing level value (represented by a hexadecimal value). When the serial port tool sends data containing the log printing level value to the smart module serial port, the smart module parses and sets its printing level. After that, the log output of the smart module is carried out according to the new printing level. Therefore, the current smart module log printing level setting specification currently only supports setting the module printing level through serial port data communication. Once the module has been assembled to the whole machine, the setting of the printing level requires the module to be disassembled, which is a very troublesome process.
[0032] To solve the above problems, refer to Figure 1As shown, an embodiment of the present application provides a log level setting device for a smart device, which integrates an external device 200, a smart module 100 and a whole device 300. The three work together through an efficient communication connection to achieve refined control of the internal log management of the smart device.
[0033] Among them, the external device 200, as an interface for user interaction, can receive the user's operation instructions and send these instructions to the smart module 100. In the log management scenario, the external device 200 is configured to issue a log printing command to the smart module 100. The log printing command includes high sixteen-bit data and low sixteen-bit data. The high sixteen-bit data carries identification information, which is used to accurately specify the functional module to which the log to be printed belongs; while the low sixteen-bit data is used to clearly indicate the required log level.
[0034] Further, the intelligent module 100 is the core processing unit of the entire device, which has multiple functional modules built in, and each functional module is responsible for recording the functional logs of their respective fields. These functional logs are classified according to different levels to obtain log levels. Specifically, in some embodiments of the present application, the log levels include: NOTICE, DEBUG, WARN, ERROR and FATAL, and distinguishing the log levels can facilitate subsequent analysis and processing. When the intelligent module 100 receives a log print command from an external device 200, it will first parse the high sixteen bits and low sixteen bits of data in the command to determine the functional module and log level to which the log to be printed belongs. Subsequently, the intelligent module 100 will retrieve the corresponding functional module and filter out qualified log entries for printing according to the specified log level.
[0035] The whole device 300 is the carrier of this intelligent log management system, which carries the operation of the intelligent module 100 and the external device 200, and also provides the necessary power supply and physical connection environment. For example, it is connected to the module power supply device through the module power supply interface. The whole device 300 maintains contact with the intelligent module 100 through a stable communication interface to ensure the accurate transmission of the log printing command and the effective output of the log information.
[0036] Overall, this log level setting device for smart devices greatly improves the flexibility and efficiency of log management. Users can easily specify the log level and the functional module to be printed through the external device 200, thereby realizing accurate monitoring of the internal operating status of the smart device. At the same time, the multi-module design and flexible log level control mechanism of the smart module 100 also provide strong support for subsequent troubleshooting and performance optimization. This device is not only suitable for the development and debugging stages of various smart devices, but can also continue to play a role during the operation of the device to ensure the stability and reliability of the system.
[0037] In some embodiments of the present application, the smart module 100 is configured to: obtain the high 16-bit data in the log printing command from the log printing command, and determine whether any one or more bits in the high 16-bit data are 1. When one or more bits in the high 16-bit data are 1, the smart module 100 selects a functional module according to the number of bits that are 1, and performs log printing on the selected functional module.
[0038] Specifically, take the value of the upper 16 bits as an example: Bit0 represents the print flag of function 1, bit0 is 1, which means that function 1 prints logs, bit0 is 0, which means that function 1 does not print logs. Similarly, bit3 represents the print flag of function 4, bit3 is 1, which means that function 4 prints logs, bit3 is 0, which means that function 4 does not print logs. In this way, when the upper 16-bit value of the log printing specification is 0x00 or 0x09, the hexadecimal 0009 can be represented as binary: 0000 000000001001. In this binary number, only Bit3 (the fourth bit from the right to the left, that is, the bit of function 4) and Bit0 (the first bit on the right, that is, the bit of function 1) are 1, and the other bits are 0, which means that the logs of function 1 and function 4 are printed and output, and the logs of other function modules are not printed and output.
[0039] The smart module 100 is further configured to obtain the lower 16-bit data in the log printing command from the log printing command, and determine whether any one or more bits in the lower 16-bit data are 1. When any one or more bits in the lower 16-bit data are 1, the smart module 100 selects the log level according to the number of bits that are 1, and prints out the selected functional module according to the selected log level.
[0040] Specifically, when all five levels of printing are required to be output, the print names are 0x00 and 0x1F, and the hexadecimal 001F can be represented as binary: 0000 0000 0001 1111. In this binary number, the first five bits are all 1, so all five levels are printed.
[0041] In some embodiments of the present application, there are a total of sixteen functional modules, and the functional modules include at least: module basic information module, serial port data transceiver module, WiFi network configuration module, HTTP interface access module, MQTT message transceiver module, big data reporting module, Bluetooth function module, firmware upgrade module, remote diagnosis module, key update module, voice recognition broadcast module, production test command module, third-party platform module and automated test interface module.
[0042] Specifically, the module functions of the high 16-bit data storage, each bit represents a function, the module functions involved in the present invention include but are not limited to: function 1-module basic information module; function 2-serial port data transceiver module; function 3-WiFi network configuration module; function 4-HTTP interface access module; function 5-MQTT message transceiver module; function 6-big data reporting module; function 7-Bluetooth function module; function 8-firmware upgrade module; function 9-remote diagnosis module; function 10-key update module; function 11-speech recognition broadcast module; function 12-production test command module; function 13-third-party platform module; function 14-automatic test interface module; function 15-other modules; function 16-reserved. Among them, the bit positions of undefined function modules, that is, function 15 and function 16 are treated as reserved positions.
[0043] In some embodiments of the present application, the external device 200 is further configured to: connect to the smart module 100 in a communication connection mode corresponding to the connection state according to the connection state between the smart module 100 and the whole device 300. Figure 2 and Figure 3 As shown, in an embodiment of the present application, the log printing level of the smart module 100 is set in different scenarios, including four scenarios: when the smart module 100 is not connected to the whole product, when the smart module 100 has been assembled to the whole product but the production test phase has not been carried out, when the smart module 100 has been assembled to the whole product and the production test phase has been completed, and when the smart product has been shipped out of the factory and the user has completed the device network configuration.
[0044] In some embodiments, reference Figure 3 As shown, the steps of connecting the external device 200 to the smart module 100 include:
[0045] S100: Determine the connection status between the smart module 100 and the whole device 300, where the connection status includes a connected state and a disconnected state.
[0046] S200: When the smart module 100 and the whole machine device 300 are in a non-connected state, the external device 200 connects to the smart module 100 via serial communication and sets the log level; when the smart module 100 is not connected to the whole machine product, its log printing level can be set using serial communication. At this time, the module power supply device supplies power to the smart module 100, and the serial port tool connects to the serial communication interface of the smart module 100 and sends a log printing level setting command to it. After receiving the command, the smart module 100 parses and executes the new log printing level.
[0047] S300: When the smart module 100 and the whole device 300 are in a disconnected state, it is determined whether the whole device 300 enters the user mode.
[0048] S400: When the whole device 300 enters the user mode, the external device 200 connects to the smart module 100 through UDP communication in the same local area network and sets the log level.
[0049] When the smart module 100 has been assembled into the whole product but has not yet left the factory, there are two situations. When the smart module 100 has not been tested in the whole system, it is in STA mode (the smart module 100 is connected to the test router with a specified name). At this time, the UDP packet sending tool (the present invention refers to the production test software) is also connected to the test router and is in the same local area network as the smart module 100, and then sends the log printing level setting command.
[0050] S500: When the whole device 300 has not entered the user mode, it is determined whether the whole device 300 has completed network configuration.
[0051] S600: When the whole device 300 completes the network configuration, the cloud interface of the external device 200 remotely connects to the smart module 100 and sets the log level.
[0052] When the smart module 100 has completed the test of the whole system, it is in AP mode (the smart module 100 starts the WiFi hotspot identified by the whole device 300). At this time, the UDP packet sending tool actively scans and connects to the WiFi hotspot identified by the whole device 300, and sends the log printing level setting command after establishing UDP communication.
[0053] S700: When the whole device 300 has not completed the network configuration, the external device 200 connects to the smart module 100 through UDP communication in a point-to-point manner and sets the log level.
[0054] When the user has completed the equipment network configuration after the smart product has been shipped, the user can send a command for setting the log printing level to the online smart module 100 through the cloud remote interface, and then further request the smart module 100 to report the data under the new printing level to the cloud, so as to meet the remote analysis of the log information of the smart module 100 and solve the problem of remote diagnosis of faults of smart devices.
[0055] Specifically, in an embodiment of the present application, before the smart module 100 is assembled, serial data communication can be used to set the module printing level. When the smart module 100 is assembled to the whole device 300, it is inconvenient to disassemble. The present application proposes a printing level setting method for the smart module 100 of the whole device 300 in two different states before and after network configuration. When the smart module 100 is not configured with a network, it is in an AP state (i.e., a WiFi hotspot marked with a device). After the UDP communication tool is connected to the hotspot of the smart module 100, the two communicate using UDP data to set the module's log printing level. When the smart module 100 completes network configuration (i.e., is connected to a home router), the cloud platform can send a new log printing level setting command through a specific interface according to the identification information of the online device, requiring the smart module 100 to switch to a new printing level.
[0056] It can be seen from the above embodiments that the present application provides a log level setting device for a smart device, and uses 4-bit hexadecimal data to represent the log level of the smart module 100, and the overall command content can be set to: A6 A6 2C09 2001 00 02A4.
[0057] A6 A6 is the command header of the entire data, which is used for the smart module 100 to confirm the validity of the data after receiving the external command. 2C represents the command number, that is, the valid command is the setting of the log printing level. 09 represents the overall data length. 20 01 represents the functional modules involved. According to the analysis of the specification of the present invention, it represents that the functional module 1 and the functional module 14 need to print the log. 00 02 represents that the functional module printing level is set to the second level (ERROR). A4 represents the checksum of the entire data command. Combined with the data length represented by 09, it is used for the smart module 100 to perform integrity check on the command content after receiving a valid print level setting command.
[0058] It can be seen from the above content that the present application provides a log level setting device for intelligent devices. The intelligent module log printing level is saved using 32-bit data, of which the upper 16 bits store the function module information and the lower 16 bits store the log level information. The function module information and the log level information jointly constrain the printing level, making the overall module log printing level setting more flexible and accurate. In addition, in addition to the existing serial communication setting method, the log printing level setting method also adds a UDP communication setting method and a remote setting method for online devices through a cloud interface. Different setting methods meet the log level setting requirements of the intelligent module in different application scenarios, and the usage scenarios are more flexible.
[0059] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the disclosure of the specification and the examples. This application is intended to cover any modifications, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure.
Claims
1. A log level setting device for an intelligent device, characterized in that: include: An external device, an intelligent module and a complete device, wherein the external device is communicatively connected to the intelligent module, and the intelligent module is communicatively connected to the complete device; The smart module includes a plurality of functional modules, each of which is configured to record a functional log according to a log level; The external device is configured to: issue a log printing command to the smart module, the log printing command comprising high-order 16-bit data and low-order 16-bit data, the high-order 16-bit data is used to indicate the functional module to be printed, and the low-order 16-bit data is used to indicate the log level to be printed; The smart module is configured to: receive the log printing command, and print the function log according to the log printing command.
2. The log level setting device of a smart device according to claim 1, characterized in that: There are sixteen functional modules in total, and the functional modules include at least: module basic information module, serial port data transceiver module, WiFi network configuration module, HTTP interface access module, MQTT message transceiver module, big data reporting module, Bluetooth function module, firmware upgrade module, remote diagnosis module, key update module, voice recognition broadcast module, production test command module, third-party platform module and automated test interface module.
3. The log level setting device of a smart device according to claim 1, characterized in that: The log levels include: NOTICE, DEBUG, WARN, ERROR, and FATAL.
4. The log level setting device for a smart device according to claim 1, characterized in that: The external device is further configured to: according to the connection status between the smart module and the whole device, connect to the smart module in a communication connection mode corresponding to the connection status.
5. The log level setting device for a smart device according to claim 4, characterized in that: The step of the external device connecting to the smart module in a communication connection mode corresponding to the connection state according to the connection state between the smart module and the whole device comprises: Determine the connection status between the smart module and the whole device, where the connection status includes a connected state and a disconnected state; When the smart module and the whole device are in a disconnected state, the external device is connected to the smart module via serial port communication and sets the log level; When the smart module and the whole device are in a disconnected state, determining whether the whole device enters a user mode; When the whole device enters the user mode, the external device connects to the smart module through UDP communication on the same local area network and sets the log level; When the whole device does not enter the user mode, determining whether the whole device has completed network configuration; When the whole device completes the network configuration, the external device cloud interface remotely connects to the smart module and sets the log level; When the network configuration of the whole device is not completed, the external device connects to the smart module through UDP communication in a point-to-point manner and sets the log level.
6. The log level setting device of a smart device according to claim 1, characterized in that: The smart module is further configured to: obtain the upper sixteen bits of data in the log printing command from the log printing command, and determine whether any one or more bits in the upper sixteen bits of data are 1; When one or more bits in the high 16-bit data are 1, the intelligent module selects the functional module according to the number of bits that are 1, and prints a log for the selected functional module.
7. The device for setting a log level of an intelligent device according to claim 6, characterized in that: The smart module is further configured to: obtain the lower sixteen bits of data in the log printing command from the log printing command, and determine whether any one or more bits in the lower sixteen bits of data are 1; When one or more bits in the lower sixteen bits of the data are 1, the intelligent module selects the log level according to the number of bits that are 1, and prints out the selected functional module according to the selected log level.
Citation Information
Patent Citations
Dynamic adjustment method, device and system for log level and computer program product
CN118467291A