CN-122019438-A - Method for transmitting log data by embedded equipment based on low-speed communication interface
Abstract
The invention provides a method for transmitting log data by embedded equipment based on a low-speed communication interface. The method is oriented to low-power-consumption miniaturized embedded equipment, realizes reliable storage and efficient uploading of key log information, and is suitable for various application scenes such as log analysis, business audit, data analysis, event backtracking and the like of the terminal equipment of the Internet of things. Aiming at the characteristics that the storage space of the embedded equipment is limited, a large number of logs cannot be stored for a long time and the processing capacity is weak, the method realizes the continuous recording of the logs under the limited resources by reasonably controlling the size of the log file and supporting a cyclic overwriting writing mechanism.
Inventors
- WANG SHUAIQIANG
- WANG RUI
- YU JINGYANG
Assignees
- 北京天御云安科技有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20251224
Claims (3)
- 1. A method for transmitting log data by embedded equipment based on a low-speed communication interface is characterized by comprising the following four steps: step one, the embedded system sets the fixed block size of the log record file and the maximum number of the log record file; Sequentially writing the log information of the embedded equipment into a log record file with a fixed size by a cyclic replacement method; Thirdly, automatically constructing a virtual index by the system according to the current writing position and the time stamp or the number of the file, and splicing all independent recorded files into a complete record stream arranged in time sequence by the index; And fourthly, the upper computer reads one record file according to the sequence or at will, and the embedded equipment communicates through the SLIP protocol format according to the received read request and transmits the log file to the upper computer.
- 2. The method according to step three of claim 1, wherein the physical log files are mapped from old to new in time sequence into virtual file sequences of the upper computer through the ring pointer and the file mapping table, and the physical storage files are mapped from old to new in time sequence into indexes of the upper computer virtual files through the file mapping table.
- 3. The method of claim 1, wherein the embedded device and the host computer communicate using a SLIP protocol, the SLIP uses two special characters to implement data encapsulation, END (0 xC 0) identifies the start and END of the data packet, and ESC (0 xDB) is used to escape the special characters, and if END occurs in the data, esc+0 xDC is replaced, and if ESC occurs in the data, esc+0 xDD is replaced.
Description
Method for transmitting log data by embedded equipment based on low-speed communication interface Technical Field The invention relates to the technical field of data communication, in particular to a method for reliably transmitting log files to an upper computer by embedded equipment based on a low-speed communication interface, which is suitable for various application scenes such as log analysis, business audit, data analysis, event backtracking and the like of terminal equipment of the Internet of things. Background With the rapid development of the fields of the internet of things, industrial automation, intelligent wearable equipment and the like, the embedded equipment has been widely applied to a plurality of key scenes such as intelligent home control, industrial field monitoring, vehicle-mounted electronic systems, medical portable terminals and the like by virtue of the core characteristics of small size, low power consumption and strong stability. In the application scenario, the operation log data (including system state information, fault alarm information, data interaction records and the like) of the embedded equipment is a core basis for equipment debugging, fault investigation and operation state evaluation, and has irreplaceable functions for guaranteeing stable operation of the equipment and improving operation and maintenance efficiency. However, the embedded device is limited by key factors such as hardware cost, volume and power consumption control, the built-in memory module (such as flash memory and EEPROM) has the common problem of limited capacity, and cannot store a large amount of log data for a long time, meanwhile, considering requirements such as cost control, communication distance adaptation and power consumption optimization in practical application, most of communication interfaces externally provided by the embedded device are low-speed communication interfaces, such as RS-232, RS-485 and I2C, SPI, loRa, and the data transmission rate of the interfaces is far lower than that of high-speed communication interfaces such as Ethernet and WiFi. In the practical application process, the transmission bandwidth limitation of the low-speed communication interface causes that the embedded device is difficult to transmit generated log data to an external storage device or an upper computer system in real time, the limited local storage space cannot support long-term retention of the log data, and when the storage space is full, the newly generated log data can cover old data, so that history log is lost, and further, the later fault tracing and operation rule analysis of the device are greatly hindered. Aiming at the technical problems, the prior industry lacks a high-efficiency and reliable log data transmission method which is required to be simultaneously adapted to the characteristics of a low-speed communication interface of embedded equipment and can effectively solve the problem of insufficient local storage capacity. Therefore, it is needed to propose a log data transmission scheme of an embedded device based on a low-speed communication interface, so as to realize efficient and stable transmission and long-term retention of log data, and meet the actual requirements of full life cycle operation and maintenance of the embedded device. Aiming at the characteristics that the storage space of the embedded equipment is limited and a large number of logs cannot be stored for a long time, the invention provides a method for transmitting log data by the embedded equipment based on a low-speed communication interface, and aims at realizing continuous recording of the logs under limited resources by reasonably controlling the size of log files and supporting a cyclic overwriting writing mechanism. The method is oriented to low-power-consumption miniaturized embedded equipment, realizes reliable storage and efficient uploading of key log information, and is suitable for various application scenes such as log analysis, business audit, data analysis, event backtracking and the like of the terminal equipment of the Internet of things. The patent document CN106919479A (application number: 201510984551.0) discloses a real-time log recording method of an embedded equipment controller, which comprises the steps of judging whether the embedded equipment controller has a file system, storing log information in a file mode if the file system exists, judging whether the number of idle bytes in a communication port buffer is larger than the length of the log information to be transmitted if the file system does not exist, copying the data of the log information into a transmission buffer of the communication port when the communication port is in a non-busy state if the number of idle bytes in the communication port buffer is larger than or equal to the length of the log information, resetting the memory address and the transmission length of the DMA, and enabling DMA transmission. The technolo