A method, device, electronic device and medium for obtaining log information

By receiving and parsing the commands of the host computer, using function pointers to obtain log information and package it to the host computer, the problem of cumbersome acquisition of controller log information in the existing technology is solved, real-time log information acquisition is achieved, and debugging efficiency is improved.

CN114002987BActive Publication Date: 2024-11-15HANGZHOU HOLLYSYS AUTOMATION
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111293612.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-03
Publication Date
2024-11-15
Estimated Expiration
2041-11-03

AI Technical Summary

Technical Problem

In the prior art, it is cumbersome to obtain unprinted log information of the controller and the controller running on site does not allow re-burning of the program, resulting in difficulty in obtaining the log information.

Method used

By receiving the command sent by the upper computer, the corresponding function is obtained by parsing the command, the function is obtained through the function pointer, the function is executed to obtain the log information, and the UDP header and log information are packaged and sent to the upper computer, real-time acquisition of the controller's log information.

Benefits of technology

It simplifies the process of obtaining log information, allows real-time acquisition of the controller's running log information, facilitates debugging and positioning problems, and improves the controller's maintenance efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114002987B_ABST
    Figure CN114002987B_ABST
Patent Text Reader

Abstract

The present application discloses a method, device, electronic device and medium for obtaining log information, mainly relating to the field of data transmission. The method is applied to a controller, and after receiving a command sent by a host computer, the command is parsed to obtain a corresponding function, and then the address of the function corresponding to the above command is obtained through a function pointer, and then the function is executed to obtain the corresponding log information, and finally the obtained log information is sent to the host computer. The method obtains the corresponding log information by processing the command sent by the host computer, and then sends the log information to the host computer through the data transmission mode between the controller and the host computer for the user to view, and can obtain the log information of the real-time operation of the controller, which is conducive to efficiently locating the problems of the controller and facilitating the debugging of the controller program.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data transmission, and in particular to a method, device, electronic device and medium for obtaining log information. Background Art

[0002] As electronic devices are widely used, more and more problems are emerging. As a device that controls the operation of electronic devices, the importance of controllers is self-evident. When a problem occurs in a controller running on site, you need to use a serial port tool to view the controller's log information and analyze the problem.

[0003] When debugging the controller program, the current method can only obtain the printed log information. If you need to obtain the unprinted log information, you need to re-encode and add the log information to burn, and then view the log information. The process is cumbersome, and the controller running on site does not allow re-burning of the program to view the problem.

[0004] It can be seen that how to simplify the method of obtaining log information is an urgent problem to be solved by those skilled in the art. Summary of the invention

[0005] The purpose of the present application is to provide a method, device, electronic device and medium for obtaining log information, which are used to break through the current limitations of using serial port tools to obtain log information.

[0006] In order to solve the above technical problems, the present invention provides a method for obtaining log information, which is applied to a controller, and the controller is connected to a host computer, comprising:

[0007] Receive commands sent by the host computer;

[0008] Parse the above commands to get the corresponding functions;

[0009] Get the address of the function through the function pointer;

[0010] Execute this function to get log information;

[0011] Send log information to the host computer.

[0012] Preferably, before sending the log information to the host computer, it also includes:

[0013] Define the format of the UDP packet header, where the UDP packet header includes the service number, data length and CRC check;

[0014] Pack the UDP header and log information into a data packet;

[0015] Correspondingly, the above-mentioned sending of log information to the host computer includes:

[0016] Send data packets to the host computer.

[0017] Preferably, it also includes:

[0018] Divide log information into different levels;

[0019] The above-mentioned sending of log information to the host computer includes:

[0020] Send the log information corresponding to the command containing the target level to the host computer.

[0021] Preferably, it also includes:

[0022] Determine whether the network load exceeds the preset load;

[0023] If exceeded, the above-mentioned log information sent to the host computer includes:

[0024] Send log information that does not exceed the preset level to the host computer.

[0025] In order to solve the above technical problems, the present invention also provides a method for obtaining log information, which is applied to a host computer and includes:

[0026] Receive a command to call a function;

[0027] Send the above command to the controller;

[0028] Receive log information sent by the controller, wherein the log information is log information obtained by executing the function obtained by parsing the above command by the controller.

[0029] Preferably, receiving the log information sent by the controller includes:

[0030] Receive data packets sent by the controller;

[0031] Parse the data packet to obtain the service number, data length, CRC checksum and log information;

[0032] Determine whether the service number, data length and CRC check are correct;

[0033] If all are correct, the reception is successful, and a prompt of successful reception is sent to the controller;

[0034] If not all are correct, the reception fails, the log information is discarded, and an error code is sent to the controller.

[0035] Preferably, after successfully receiving the log information, the method further includes:

[0036] Display log information;

[0037] Add timestamps to log information and save them in log files.

[0038] In order to solve the above technical problems, the present invention also provides a device for obtaining log information, including:

[0039] Receiving module, used to receive commands sent by the host computer;

[0040] Parsing module, used to parse commands to get corresponding functions;

[0041] The acquisition module is used to obtain the address of the function through the function pointer;

[0042] An execution module, used to execute the function to obtain log information;

[0043] The sending module is used to send log information to the host computer.

[0044] In order to solve the above technical problems, the present invention further provides an electronic device, comprising:

[0045] Memory for storing computer programs;

[0046] A processor is used to implement the steps of the above-mentioned method for obtaining log information when executing a computer program.

[0047] In order to solve the above technical problem, the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for obtaining log information are implemented.

[0048] The present invention proposes a method for obtaining log information, which is applied to a controller, and the controller is connected to a host computer. After receiving a command sent by the host computer, the method parses the command to obtain a corresponding function; then obtains the address of the function through a function pointer; then executes the function to obtain corresponding log information; finally, sends the log information to the host computer. The method obtains corresponding log information by processing the command sent by the host computer, and then sends the log information to the host computer through a data transmission method between the controller and the host computer for user viewing. The method can obtain the log information of the real-time operation of the controller, which is conducive to efficiently locating problems in the controller and facilitating debugging of the controller program.

[0049] In addition, the device, electronic device and medium for obtaining log information provided by the present invention correspond to the method for obtaining log information, and the effects are as above. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0051] Figure 1A flowchart of a method for obtaining log information applied to a controller provided by the present invention;

[0052] Figure 2 A flowchart of a method for obtaining log information applied to a host computer provided by the present invention;

[0053] Figure 3 A structural diagram of a device for obtaining log information provided by the present invention;

[0054] Figure 4 This is a structural diagram of an electronic device provided by the present invention. DETAILED DESCRIPTION

[0055] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0056] The core of this application is to provide a method for obtaining log information. The method obtains corresponding log information by processing the command sent by the host computer, and then sends the log information to the host computer through the data transmission method between the controller and the host computer for user viewing. The log information of the controller running in real time can be obtained, which is convenient for debugging the controller program.

[0057] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0058] Figure 1 The present invention provides a flow chart of a method for obtaining log information applied to a controller. Figure 1 As shown, the method includes:

[0059] S1: Receive commands sent by the host computer.

[0060] In this embodiment, the controller is connected to the host computer. After receiving the command input by the user, the host computer sends the command to the controller through the data transmission method between the controller and the host computer, and the controller receives and processes the command.

[0061] S2: Parse the command to get the corresponding function.

[0062] In a specific implementation, the command sent by the host computer is a command to call a function. It should be noted that the function is a pre-set function and has a corresponding relationship with the command sent by the host computer. Each command has a corresponding function. Therefore, after receiving the command, the controller needs to parse the command to obtain the corresponding function.

[0063] S3: Get the address of the function through the function pointer.

[0064] The function pointer is a pre-set universal pointer, through which the address of any function stored in the controller can be obtained. In this embodiment, the address of the function obtained by parsing the command is obtained through the function pointer. In addition, when saving logs, users can output log information of places prone to problems and establish a corresponding table between commands and functions for subsequent use.

[0065] S4: Execute the function to obtain log information.

[0066] After obtaining the address of the function through the function pointer, you need to execute the function and obtain the log information according to the address corresponding to the function pointer.

[0067] S5: Send log information to the host computer.

[0068] In the specific implementation, the controller sends log information to the host computer through the User Datagram Protocol (UDP). Before sending the log information to be transmitted, the controller and the host computer need to create a socket. The controller needs to bind the socket to the UDP sending interface, and call the sending interface through the socket to send the log information to the host computer according to the IP address of the host computer, and then the host computer receives the log information through the created socket.

[0069] It should be noted that there are three types of sockets: streaming sockets, data packet sockets and raw sockets. Since the present embodiment completes data transmission via UDP, data packet sockets are used in the present embodiment. However, the reliability of data packet sockets cannot be guaranteed, which is mainly reflected in that the transmitted data may not reach the target address and there may be errors in the data contained after arrival. Since the target address in the present embodiment is the host computer and the transmitted data is log information, in order to prevent the log information from failing to reach the host computer, a response program can be set at the host computer, and different responses are made to the controller according to whether the host computer receives the log information within a preset time. If the log information is not received, the controller will resend the log information until the host computer sends the received response. In addition, in order to prevent errors in the log information received by the host computer, the controller can define the format of the UDP header so that the host computer can confirm whether the received log information is wrong based on the comparison result of the UDP header information and the locally stored header information.

[0070] This embodiment proposes a method for obtaining log information, which is applied to a controller, and the controller is connected to a host computer. After receiving a command sent by the host computer, the method parses the command to obtain a corresponding function; then, obtains the address of the function through a function pointer; then executes the function to obtain log information; finally, sends the log information to the host computer. This embodiment obtains the corresponding log information by processing the command sent by the host computer, and then sends the log information to the host computer through a data transmission method between the controller and the host computer for the user to view. The log information of the real-time operation of the controller can be obtained, which is conducive to efficiently locating problems in the controller and facilitating debugging of the controller program.

[0071] In the above embodiment, in order to prevent errors in the log information received by the host computer, the controller can define the format of the UDP header before sending the log information to the host computer, so that the host computer can confirm whether the received log information is wrong according to the UDP header. This step includes:

[0072] Define the format of the UDP packet header, where the UDP packet header includes the service number, data length and CRC check;

[0073] Pack the UDP header and log information into a data packet;

[0074] Correspondingly, the above-mentioned sending of log information to the host computer includes:

[0075] Send data packets to the host computer.

[0076] In the present embodiment, the UDP header includes a service number, a data length and a cyclic redundancy check code (CRC check), wherein the service number is a kind of identifier. The host computer can judge whether the log information in the data packet has an error according to whether the service number, data length, CRC check in the data packet is consistent with the service number, data length, and CRC check stored locally. It should be noted that the service number, data length, and CRC check are all used to verify whether the log information in the data packet has an error, and the verification content is not limited to the service number, data length, and CRC check. It can also be a data name, by comparing whether the data name in the UDP header is consistent with the data name stored locally by the host computer to judge whether the log information has an error, and the log information can also be encrypted and transmitted, and the encryption method can only be unlocked by the key stored by the host computer to improve the accuracy of the log information. In addition, the first few bytes of the data packet can be used to store the UDP header information, and the remaining bytes are used to contain the log information, so as to complete the packaging of the UDP header and the log information, and then the sending interface is called by the socket to send the data packet to the host computer according to the IP address of the host computer.

[0077] This embodiment defines the UDP header format, and packages the UDP header and log information into a data packet and sends it to the host computer, so that the host computer parses the data packet to obtain the UDP header and log information and confirms whether the received log information is wrong based on the UDP header.

[0078] In the specific implementation, when a problem occurs in the controller, it is necessary to view the controller's log information to analyze the problem. However, users often do not know the root cause of the problem and cannot efficiently view the log information corresponding to the problem. This problem can be solved by grading the log information. This step includes:

[0079] Divide log information into different levels;

[0080] The above-mentioned sending of log information to the host computer includes:

[0081] Send the log information corresponding to the command containing the target level to the host computer.

[0082] In this embodiment, the log information can be divided into five levels: Info, Debug, Warning, Error, and Fatal. When a problem occurs in the controller, the user can filter out some levels of log information for viewing based on experience. For example, the user determines based on experience that the log information to be viewed is one of the two levels of Info and Debug. At this time, the log information of the two levels of Info and Debug can be called for filtering and viewing, which can not only efficiently obtain the log information required by the user, but also prevent the controller from being overloaded due to sending too much log information. It should be noted that the controller controls the level of log information output by using a flag. After receiving a command containing a target level sent by the host computer, the controller can output the corresponding level of log information by setting 0 or 1 according to the target level. For example, when setting 0 to not output log information and setting 1 to output log information, the log information of the target level can be set to 1, and the log information of other levels can be set to 0, so as to achieve the purpose of outputting only the target log information.

[0083] In addition, after the log information is divided into levels, if some levels of log information are not needed within a period of time, the log information of that level can be closed as needed by inputting a command to close the log information of that level in the upper computer. When the log information of that level is needed again, it can be turned on again, achieving the effect of "turn on when used and turn off when not used". At the same time, it also effectively ensures that the screen will not be flooded with log information due to too much log information.

[0084] This embodiment divides the log information into different levels. After the user obtains the target level based on experience, the required log information can be obtained more efficiently, which effectively prevents the controller from being overloaded due to sending too much log information.

[0085] The above embodiment mentioned that the controller may be overloaded when sending log information to the upper computer. To avoid this situation, the network load when the controller is running can be compared with the preset maximum safe load to determine whether the current controller is overloaded, and corresponding measures can be taken when overloaded to avoid long-term overload operation and burn out the controller. This step includes:

[0086] Determine whether the network load exceeds the preset load;

[0087] If exceeded, the above-mentioned log information sent to the host computer includes:

[0088] Send log information that does not exceed the preset level to the host computer.

[0089] In this embodiment, by comparing the network load when the controller is running with the maximum safety load preset by the user, it is determined whether the controller is overloaded, and the controller log information is adjusted according to the comparison result. For example, in the above embodiment, the log information is divided into five levels: Info, Debug, Warning, Error and Fatal, and the five levels increase from left to right. The user can preset the maximum safety load to 60% of the total line load, and the preset level of the log information is Warning. If the controller receives a command sent by the host computer and needs to output log information of the three levels of Info, Debug and Fatal, but the network load of the controller exceeds the maximum safety load preset by the user when outputting the log information, the network load can be reduced by not outputting the log information of the Fatal level, without the need for manual adjustment by the user, and the resources of the controller are effectively utilized, and the running task of the controller will not be stressed. It should be noted that if the preset level of the log information is set to Warning, it should be ensured that when all log information not exceeding the preset level is output, the network load of the controller will not exceed the maximum safety load preset by the user, that is, when the log information of the three levels of Info, Debug and Warning is output at the same time, the network load of the controller is less than the preset maximum safety load, and the controller runs safely.

[0090] This embodiment determines whether the controller is overloaded by comparing the network load when the controller is running with the maximum safe load preset by the user, and takes measures to reduce the operating pressure of the controller when the controller is overloaded. No manual adjustment by the user is required, which effectively avoids the situation where the controller is burned out due to long-term overload operation and improves the safety of the controller during operation.

[0091] Figure 2 The present invention provides a flow chart of a method for obtaining log information applied to a host computer. Figure 2 As shown, the method includes:

[0092] S6: Receive a command to call a function.

[0093] In a specific implementation, the user can filter out the log information he needs based on experience, and input a command to call the corresponding function in the host computer. It should be noted that the controller can obtain the log information required by the user by executing the function. After the user input is completed, the host computer receives the command input by the user to call the function to obtain the corresponding log information.

[0094] S7: Send command to the controller.

[0095] S8: Receive log information sent by the controller, wherein the log information is log information obtained by executing the function obtained by parsing the above command by the controller.

[0096] In the above embodiment, it is mentioned that the host computer receives the log information sent by the controller through the created socket. It should be noted that when the controller sends log information to the host computer, the socket at the controller can initiate a connection to the socket at the host computer according to the IP address of the host computer. At this time, the socket at the host computer should be in a listening state to listen for a connection request. Once a connection request is received, the host computer can establish a connection or reject the connection according to the actual situation. In this embodiment, when the host computer receives a connection request from the controller, it establishes a connection with the controller and receives the log information sent by the controller.

[0097] This embodiment proposes a method for obtaining log information, which is applied to a host computer, including receiving a command to call a function, then sending the command to a controller, and receiving the log information when the controller sends corresponding log information to the host computer, wherein the log information is log information obtained by executing the function obtained by parsing the command of the controller. The method inputs a command at the host computer and transmits the command to the controller for processing to obtain log information corresponding to the command, and can obtain the log information of the controller running in real time, thereby efficiently locating the problem of the controller, so as to achieve the purpose of quickly solving the problem.

[0098] In the above embodiment, it is mentioned that in order to prevent errors in the log information received by the host computer, the controller will define the format of the UDP header before sending the log information to the host computer, and package the UDP header and the log information into a data packet and send it to the host computer. Therefore, after receiving the data packet sent by the controller, the host computer needs to parse the data packet and determine whether there are errors in the received log information through the UDP header. Only when there are no errors in the log information can the reception be confirmed to be successful. The receiving step includes:

[0099] Receive data packets sent by the controller;

[0100] Parse the data packet to obtain the service number, data length, CRC checksum and log information;

[0101] Determine whether the service number, data length and CRC check are correct;

[0102] If all are correct, the reception is successful, and a prompt of successful reception is sent to the controller;

[0103] If not all are correct, the reception fails, the log information is discarded, and an error code is sent to the controller.

[0104] In this embodiment, the service number, data length and CRC check are compared with the service number, data length and CRC check stored locally in the host computer to determine whether there is an error in the log information. In order to improve the accuracy of the log information, only when the service number, data length and CRC check are all correct, it is determined that there is no error in the log information, the reception is successful, and a prompt of successful reception is sent to the controller; otherwise, it is determined that the reception fails, the log information in the data packet is discarded, and an error code is sent to the controller. After receiving the error code, the controller will repackage the data packet and send it to the host computer.

[0105] This embodiment receives a data packet sent by the controller, and parses the data packet to obtain a UDP packet header and log information. It determines whether there is an error in the log information by comparing the service number, data length and CRC check of the data packet with the service number, data length and CRC check stored locally on the host computer. Only when all are consistent can it be determined that there is no error in the log information, which can effectively improve the accuracy of the log information.

[0106] After determining that there is no error in the log information in the above embodiment and successfully receiving the log information, the host computer also needs to display the log information for the user to view. In order to facilitate the user to view the historical records later, the log information can also be saved with a timestamp. This step includes:

[0107] Display log information;

[0108] Add timestamps to log information and save them in log files.

[0109] This embodiment displays the log information after successfully receiving the log information for the user to view, and adds a timestamp to the displayed log information and saves it in a log file set by the user for subsequent viewing of the historical records.

[0110] In the above embodiments, the method for obtaining log information is described in detail, and the present application also provides an embodiment corresponding to the device for obtaining log information. It should be noted that the present application describes the embodiments of the device part from two perspectives, one is based on the perspective of functional modules, and the other is based on the perspective of hardware.

[0111] Figure 3 This is a structural diagram of a device for obtaining log information provided by the present invention. Figure 3 As shown, the device comprises:

[0112] The receiving module 10 is used to receive commands sent by the host computer;

[0113] A parsing module 11, used for parsing commands to obtain corresponding functions;

[0114] An acquisition module 12 is used to acquire the address of a function through a function pointer;

[0115] An execution module 13, used for executing a function to obtain log information;

[0116] The sending module 14 is used to send log information to the host computer.

[0117] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.

[0118] Figure 4 A structural diagram of an electronic device provided in another embodiment of the present application, such as Figure 4 As shown, the electronic device includes: a memory 20 for storing a computer program;

[0119] The processor 21 is used to implement the steps of the method for obtaining log information mentioned in the above embodiment when executing the computer program.

[0120] The electronic device provided in this embodiment may include but is not limited to a smart phone, a tablet computer, a laptop computer or a desktop computer.

[0121] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 can be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 21 may be integrated with a graphics processing unit (GPU), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.

[0122] The memory 20 may include one or more computer-readable storage media, which may be non-transitory. The memory 20 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 20 is at least used to store the following computer program 201, wherein, after the computer program is loaded and executed by the processor 21, it can implement the relevant steps of the method for obtaining log information disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 20 may also include an operating system 202 and data 203, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 202 may include Windows, Unix, Linux, etc. Data 203 may include but is not limited to log information, etc.

[0123] In some embodiments, the electronic device may further include a display screen 22 , an input / output interface 23 , a communication interface 24 , a power source 25 , and a communication bus 26 .

[0124] Those skilled in the art will understand that Figure 4 The structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than those shown in the figure.

[0125] Finally, the present application also provides an embodiment corresponding to a computer-readable storage medium. A computer program is stored on the computer-readable storage medium, and when the computer program is executed by the processor, the steps recorded in the above method embodiment (which may be the method corresponding to the controller side, the method corresponding to the host computer side, or the method corresponding to the controller side and the host computer side) are implemented.

[0126] It is understandable that if the method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.

[0127] The above is a detailed introduction to the method, device, electronic device and medium for obtaining log information provided by the present application. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the embodiments can refer to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can refer to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.

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

Claims

1. A method for obtaining log information, characterized in that: Applied to a controller, the controller is connected to a host computer, and the controller is a device for controlling the operation of an electronic device; wherein the method comprises: Receiving a command for calling a function sent by the host computer; Parsing the command to obtain the corresponding function; Obtain the address of the function through the function pointer; Execute the function to obtain log information; Sending the log information to the host computer; Wherein, the method further comprises: Classifying the log information into different levels; The sending of the log information to the host computer comprises: Sending the log information corresponding to the command including the target level to the host computer; Also includes: Determine whether the network load exceeds the preset load; If it exceeds, sending the log information to the host computer includes: Sending the log information that does not exceed the preset level to the host computer; Also includes: When the preset response program located in the host computer detects that the host computer has not received the log information within the preset time, the process jumps back to the step of sending the log information to the host computer.

2. The method for obtaining log information according to claim 1, characterized in that: Before sending the log information to the host computer, the method further includes: Define the format of the UDP packet header, wherein the UDP packet header includes a service number, data length and CRC check; Packing the UDP packet header and the log information into a data packet; Correspondingly, the sending the log information to the host computer includes: Send the data packet to the host computer.

3. A method for obtaining log information, characterized in that: Applied to the host computer, including: Receive a command to call a function; Sending the command to a controller; the controller is a device for controlling the operation of an electronic device; Receiving log information sent by the controller, wherein the log information is log information obtained by executing a function obtained by parsing the command by the controller; Wherein, the method further comprises: receiving the log information corresponding to the command including the target level, which is sent by the controller by classifying the log information into different levels; Also includes: receiving the log information that does not exceed a preset level and is sent by the controller when the controller determines that the network load exceeds a preset load; Also includes: When the preset response program detects that it has not received the log information within the preset time, it jumps back to the step of receiving the log information sent by the controller.

4. The method for obtaining log information according to claim 3, characterized in that: The receiving log information sent by the controller includes: receiving a data packet sent by the controller; Parse the data packet to obtain the service number, data length, CRC checksum and log information; Determine whether the service number, the data length and the CRC check are correct; If all are correct, the reception is successful, and a prompt of successful reception is sent to the controller; If not all are correct, the reception fails, the log information is discarded, and an error code is sent to the controller.

5. The method for obtaining log information according to claim 4, characterized in that: After successfully receiving the log information, the method further includes: Display the log information; A timestamp is added to the log information and saved in a log file.

6. A device for obtaining log information, characterized in that: Applied to a controller, the controller is connected to a host computer, and the controller is a device for controlling the operation of an electronic device; wherein the device comprises: A receiving module, used for receiving a command for calling a function sent by a host computer; A parsing module, used for parsing the command to obtain a corresponding function; An acquisition module, used for acquiring the address of the function through a function pointer; An execution module, used for executing the function to obtain log information; A sending module, used for sending the log information to the host computer; The device is also used to: classify the log information into different levels; The sending module is used to: send the log information corresponding to the command containing the target level to the host computer; The device is also used to: determine whether the network load exceeds a preset load; If it exceeds, the sending module is used to: send the log information that does not exceed the preset level to the host computer; The device is also used for: when the preset response program located in the host computer detects that the host computer has not received the log information within a preset time, jumping back to the step of sending the log information to the host computer.

7. An electronic device, characterized in that: comprising a memory for storing a computer program; A processor, configured to implement the steps of the method for obtaining log information as described in any one of claims 1 to 5 when executing the computer program.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for obtaining log information according to any one of claims 1 to 5 are implemented.