WO2020107430A1 - 日志存储方法、日志读取方法、智能电池、无人机 - Google Patents

日志存储方法、日志读取方法、智能电池、无人机 Download PDF

Info

Publication number
WO2020107430A1
WO2020107430A1 PCT/CN2018/118654 CN2018118654W WO2020107430A1 WO 2020107430 A1 WO2020107430 A1 WO 2020107430A1 CN 2018118654 W CN2018118654 W CN 2018118654W WO 2020107430 A1 WO2020107430 A1 WO 2020107430A1
Authority
WO
WIPO (PCT)
Prior art keywords
log
flag
value
storage unit
flag bit
Prior art date
Application number
PCT/CN2018/118654
Other languages
English (en)
French (fr)
Inventor
江帆
房玲江
龚如
Original Assignee
深圳市大疆创新科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市大疆创新科技有限公司 filed Critical 深圳市大疆创新科技有限公司
Priority to PCT/CN2018/118654 priority Critical patent/WO2020107430A1/zh
Priority to CN201880069257.9A priority patent/CN111433765A/zh
Publication of WO2020107430A1 publication Critical patent/WO2020107430A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data

Definitions

  • the embodiments of the present invention relate to the technical field of smart batteries, and in particular to log storage methods, log reading methods, smart batteries, and drones.
  • the storage and computing resources of the battery microprocessor MCU in the UAV are limited, and an external flash memory device FLASH is required to store log information to record the battery status and locate battery abnormalities.
  • the limited resources of the microprocessor MCU will conflict with the resources consumed by storing logs, which affects the efficiency of log storage.
  • Embodiments of the present invention provide a log storage method, log reading method, smart battery, and unmanned aerial vehicle.
  • an embodiment of the present invention provides a log storage method, including:
  • Reading log header information the log header information includes flag information
  • an embodiment of the present invention provides a log reading method, including:
  • Reading log header information the log header information includes flag information
  • the log is sequentially read from the starting minimum storage unit until reaching the starting minimum storage unit.
  • an embodiment of the present invention provides a smart battery, including a processor and a memory that stores executable instructions of the processor, and the processor communicates with the memory for reading an executable from the memory Instructions to achieve:
  • Reading log header information the log header information includes flag information
  • an embodiment of the present invention provides a log reading device, including:
  • Reading log header information the log header information includes flag information
  • the log is sequentially read from the starting minimum storage unit until reaching the starting minimum storage unit.
  • an embodiment of the present invention provides a drone including at least an airframe and a smart battery, a power system, and a flight controller according to the third aspect provided on the airframe.
  • the smart battery can be The power supply system provides power for the UAV.
  • an embodiment of the present invention provides a machine-readable storage medium that stores a number of computer instructions, and when the computer instructions are executed, the steps of the log storage method of the first aspect are implemented.
  • an embodiment of the present invention provides a machine-readable storage medium having a plurality of computer instructions stored on the machine-readable storage medium. When the computer instructions are executed, the steps of the log reading method of the second aspect are implemented .
  • the log header information when there is a need to store the log, the log header information is read; then, according to the value of each flag bit in the flag information, determine whether to write the log to the flash memory In the device. For example, when the value of the flag bit is the first preset value, the log is written to the storage unit corresponding to the flag bit in the flash memory device. As another example, when no flag bit takes the value of the first preset value, the log is not stored. It can be seen that in this embodiment, the storage unit can be determined through the log header information, and it is not necessary to detect each storage unit, thereby reducing the detection time. In addition, in this embodiment, there is no need to write the log to be saved into the originally stored log, thereby reducing the amount of data processing and the size of the cache occupied during the process of storing the log, and reducing the demand for resources.
  • FIG. 1 is a schematic flowchart of a log storage method provided by an embodiment of the present invention.
  • FIG. 2 is a schematic flowchart of verifying the validity of a signature provided by an embodiment of the present invention
  • FIG. 3 is a schematic flowchart of determining whether a signature is legal according to an embodiment of the present invention
  • FIG. 4 is a schematic flowchart of determining a minimum storage unit according to a serial number provided by an embodiment of the present invention
  • FIG. 5 is a schematic flowchart of a log reading method provided by an embodiment of the present invention.
  • 6 and 7 are schematic diagrams of the minimum storage units and corresponding flag bits in a flash memory device according to an embodiment of the present invention.
  • FIG. 8 is a block diagram of a smart battery provided by an embodiment of the present invention.
  • FIG. 9 is a block diagram of a log reading device provided by an embodiment of the present invention.
  • the storage and computing resources of the battery microprocessor MCU in the UAV are limited, and an external flash memory device FLASH is required to store log information to record battery status and locate battery abnormalities.
  • an external flash memory device FLASH is required to store log information to record battery status and locate battery abnormalities.
  • the limited resources of the microprocessor MCU will conflict with the resources consumed by storing logs, which affects the efficiency of log storage.
  • an embodiment of the present invention provides a log storage method.
  • the inventive concept is to set log header information and read the log header information when there is a need to store the log.
  • the log header information includes flag information; then, according to The value of each flag bit in the flag information can determine whether to write the log to the flash memory device. For example, when the value of the flag bit meets the requirements, the log may be stored in the smallest storage unit corresponding to the flag bit, and the flash memory device includes a plurality of smallest storage units.
  • the minimum storage unit refers to the smallest operation that can be performed each time the flash memory device is erased, for example, 4K bits.
  • the technician can also adjust the size of the minimum storage unit according to the specific scenario, and the corresponding solution falls within the protection scope of the present application.
  • FIG. 1 is a schematic flowchart of a log storage method provided by an embodiment of the present invention. Referring to FIG. 1, it can be applied to electronic devices such as smart batteries and battery housekeepers. For convenience of description, a smart battery is used as an example for description.
  • a log storage The method includes step 101 and step 102, where:
  • the log header information may be set in advance, and the content of the log header information may be specifically set according to specific scenarios. Refer to Table 1, which shows a log header information provided in this embodiment.
  • the signature is used to verify the validity of the log header information.
  • the value of the signature can be used to determine whether the signature is legal. When it is legal, there is a valid minimum storage unit in the flash memory device. In this case, the log can be stored To the effective minimum storage unit; when it is illegal, there is no effective storage unit in the flash memory device, in this case, the log cannot be stored in the flash memory device.
  • the default value of the signature value may be but not limited to 0xAA55.
  • the value of the flag bit information will change, and accordingly, the default value of the signature will also change accordingly.
  • the ratio or number of effective minimum storage units in the flash memory device to all storage units can be determined.
  • the signature is only changed from the default value to 0xFFFF when all the smallest storage units in the flash memory device are unavailable. In this embodiment, the signature is changed in this way.
  • the flag information includes multiple flag bits.
  • the flag bits can be of different lengths, thereby indicating the effective state of multiple storage units (available or unavailable).
  • the length of the flag bit is 2 bits, it can represent 4 states, namely 00, 01, 10, and 11. According to the change of the flag bit from 00 to 11 or from 11 to 00, the corresponding minimum storage unit can be determined The effective state of.
  • the length of the flag bit is 1 bit, which can indicate 2 states, that is, 0 indicates that the minimum storage unit is unavailable, and 1 indicates that the minimum storage unit is available. The technician can select the length of the flag bit according to the specific scenario. If the solution of the present application can be implemented, the corresponding solution falls within the protection scope of the present application.
  • write operations can only change the data bits in the smallest storage unit from 1 to 0, and erase operations can only change the data bits in the smallest storage unit from 0 to 1.
  • the length of the flag bit is 1 bit (1 bit).
  • the value of the flag bit may be the first preset value or the second preset value.
  • the first preset value is 1, the second The preset value is 0, and subsequent embodiments use this value as an example to describe the solution.
  • the number of flag bits is the same as the number of the smallest storage unit in the flash memory device, so that the flag bits in the flag information and the smallest storage unit in the flash memory device have a one-to-one correspondence relationship.
  • the log header information further includes a flag length
  • the flag length represents the effective value range of all the flag bits in the flag information.
  • the effective value range is strongly related to the number of minimum storage units in the flash memory device. For example, the minimum number of storage units is 4096, the effective value range can be 1-4096 (or 0-4095), etc., which can avoid judging the value of the flag bit beyond the effective value range and reducing the amount of data processing.
  • the mark length is used to indicate how many minimum storage units in the flash memory device can store logs without storing logs.
  • the length of the flag may not be set in the log header information.
  • the log header information may include at least one of the following: signature, mark length, and mark information.
  • the log header information may include flag information. It should be noted that the composition of the log header information can be set according to specific scenarios, and is not limited here.
  • the log header information may be stored in a local storage, cache, or cloud, and may also be stored in a flash memory device.
  • the log header information is stored in a minimum storage unit of the flash memory device.
  • the minimum storage unit may be the first or last storage unit in the flash memory device, so as to facilitate querying, reading and refreshing.
  • the smart battery can read the log header information from the flash memory device when it detects that a log needs to be saved, and can read all the log header information or only the flag information when reading.
  • the smart battery after detecting the re-power on, the smart battery detects the validity of the signature in the log header information before writing the log into the flash memory device (corresponding to step 201).
  • the step of determining whether to write the log to the flash memory device according to the value of each flag bit in the flag information (corresponding to step 203) is executed, that is, step 102 is executed;
  • the log header information is re-initialized, and the step of reading the log header information (corresponding to step 204) is continued, that is, step 102 is performed.
  • step 203 and step 204 is in no particular order, including at least one of the following: step 203 is executed before step 204, step 204 is executed before step 203, and step 203 and step 204 are executed simultaneously .
  • the validity of the signature in the verification header information of the smart battery may include: referring to FIG. 3, the smart battery acquires the current value of the signature in the log information (corresponding to step 301). then. The smart battery compares the current value and the preset value (ie, the default value) (corresponding to step 302). When the current value and the preset value are equal, the smart battery determines that the signature is legal (corresponding to step 303), and the current value and the preset value are different At that time, the smart battery determines that the signature is invalid (corresponding to step 304). In this embodiment, by determining whether the log header information is legal,
  • the smart battery After reading the flag information, the smart battery can obtain the value of each flag bit in the flag information. Acquisition methods can include:
  • the smart battery can randomly read the value of each flag bit, and then select a flag bit whose value is the first preset value.
  • Method 2 The smart battery can read the value of each flag bit in sequence according to the flag bit order. Then, select a flag bit that takes the first preset value.
  • Method 3 The smart battery can read the value of each flag bit randomly or sequentially. If the value of the flag bit is the second preset value, continue to read the flag bit until a flag bit value is read Until the first preset value.
  • the number of erasing times of each storage unit in the flash memory device is limited, the number of erasing times of each storage unit is balanced, that is, in this embodiment, the method of sequentially storing logs to each minimum storage unit is used to achieve the effect of balancing the number of erasing times .
  • the value of the flag bit is acquired in the third way.
  • determining the location of the smallest storage unit may include: referring to FIG. 4, when the smart battery detects the flag bit whose value is the first preset value, it may determine the serial number of the flag bit (corresponding to step 401). In some scenarios, the serial number is the serial number of the first flag bit that takes the value of the first preset value. Then, based on the relationship between the serial number and the offset address, the smart battery obtains the offset address of the smallest storage unit corresponding to the flag bit in the flash memory device according to the serial number of the flag bit (corresponding to step 402).
  • the smart device sequentially writes the logs into the smallest storage unit corresponding to the offset address (corresponding to step 403).
  • logs are sequentially written to each minimum storage unit, thereby ensuring that the number of erasures of each minimum storage unit remains the same (or similar), achieves the effect of equalization of erasing and writing, and prolongs the service life of the flash memory device.
  • each minimum storage unit is fixed, for example, 4K bytes.
  • the physical address (ie, the first address) of the first storage unit in the flash memory device is also fixed, so the relationship between the serial number and the offset address can be determined according to the size and serial number of each minimum storage unit. For example, if the physical address of the first storage unit is 0x00FF and the serial number is 2, the offset address of the second smallest storage unit can be obtained as 2*4K bytes. Then, the smart battery is combined with the physical address of the first storage unit to obtain the physical address of the second smallest storage unit. For easy reference, you can create a table of serial numbers and offset addresses in advance and store them in a cache, local storage, or cloud.
  • the smart setting modifies the value of the corresponding flag bit from the first preset value to the second preset value before, after, or at the same time as erasing the smallest storage unit, so that the state of the smallest storage unit is changed from "available" Becomes "unavailable”.
  • the length of the log can be adjusted.
  • a 128-byte log is used as an example for description.
  • Table 1 shows the log format
  • Table 2 is a description of the contents of each part in the log
  • the smart battery writes a 128-byte log into the smallest storage unit at a time until the smallest storage unit is full of logs. After that, the smart battery acquires the next flag bit that takes the first preset value.
  • the starting position may be the first flag bit of all flag bits, or the flag bit corresponding to the smallest storage unit that has just filled the log. Then return to step 101.
  • the smart device After the smart device detects all the flag bits in the flag information, if the flag information does not include the flag bits with the first preset value, that is, when all the flag bits have the second preset value, Then refresh the log header information.
  • refreshing the log header information not only refreshes the signature, but also refreshes the flag information.
  • refresh flag information the values of all flag bits in the flag information are adjusted from the second preset value to the first preset value. After refreshing the log header information, it indicates that all the minimum storage units of the flash memory device are in the "available" state. In other words, all the minimum storage units undergo a single erasing operation, so that each minimum storage unit has the same (or similar) number of erasures to achieve a balance The effect of the number of erasures.
  • the log header information when there is a need to store the log, the log header information is read; then, according to the value of each flag bit in the flag information, it is determined whether to write the log in the flash memory device. For example, when the value of the flag bit is the first preset value, the log is written to the storage unit corresponding to the flag bit in the flash memory device. As another example, when no flag bit takes the value of the first preset value, the log is not stored. It can be seen that in this embodiment, the storage unit can be determined through the log header information, and it is not necessary to detect each storage unit, thereby reducing the detection time. In addition, in this embodiment, there is no need to write the log to be saved into the originally stored log, which can reduce the amount of data processing and the size of the cache occupied in the process of storing the log, and reduce the demand for resources.
  • FIG. 5 is a schematic flowchart of a log reading method provided by an embodiment of the present invention, which can be applied to a log Reading device.
  • the log reading device may be an electronic device such as a mobile terminal, a smart battery, a reading card, a tablet computer, a personal computer, and the following description will continue with the smart battery as an example.
  • a log reading method includes steps 501 to 503, in which:
  • step 501 and step 101 are the same.
  • FIG. 1 and related content of step 101 please refer to FIG. 1 and related content of step 101, which will not be repeated here.
  • the smart battery obtains the value of each flag bit in the flag information, obtains the first flag bit whose value is the first preset value, and uses the minimum storage unit corresponding to the first flag bit as the read log The smallest storage unit of the beginning.
  • the smart device obtains the value of each flag bit and the initial minimum storage unit, and the relevant content of method 3 in FIG. 1 and step 102 may be used, and details are not described herein again.
  • the smart battery can also obtain the value of each flag bit in the flag information to obtain the flag bit whose value is the first preset value, and use the minimum storage unit corresponding to one of the flag bits as the minimum storage at the beginning of reading the log
  • the unit can also implement the solution of the present application, which will not be repeated here.
  • the smart battery determines the initial minimum storage The unit is the first unit whose value of the flag bit is the second preset value.
  • the smart battery sequentially reads the logs stored in the flash memory device from the initial minimum storage unit, returns to the first minimum storage unit of the flash memory device after reading the last storage unit, and continues to read the log until it reaches Determine the starting minimum storage unit.
  • the smart battery reads each minimum storage unit in the flash memory device in sequence from the initial minimum storage unit, thereby obtaining all logs.
  • the initial minimum storage unit is the minimum storage unit whose value is the second preset value and which corresponds to the nearest flag bit of the first flag bit whose value is the first preset value, in this case Next, you can read the logs from new to old.
  • FIG. 6 is a schematic diagram of the minimum storage units and corresponding flag bits in a flash memory device according to an embodiment of the present invention.
  • the smart battery determines that the flag bit with the first preset value is line 3
  • the last one (3, 3) uses different fonts to distinguish other minimum storage units, indicating that it returns to the initial minimum storage unit, and no more data is read.
  • the smart battery can read all the logs stored in the flash memory device, and the log time is from old to new.
  • the smart battery can also read the logs stored in each minimum storage unit in the reverse direction, the reading order is:
  • the smart battery can read all the logs stored in the flash memory device, and the log time is from new to old.
  • the smart battery determines the initial minimum storage The unit is the first unit whose value of the flag bit is the second preset value.
  • FIG. 7 is a schematic diagram of each minimum storage unit and corresponding flag bit values in a flash memory device provided by an embodiment of the present invention.
  • a smart battery reads logs stored in each minimum storage unit, and the reading order is:
  • the smart battery can read all the logs stored in the flash memory device, and the log time is from old to new.
  • the initial minimum storage unit can be determined through the log header information, and then all logs from old to new or new to old can be read to improve the reading efficiency.
  • a smart battery 800 includes a processor 801 and a memory 802 storing executable instructions of the processor 801.
  • the processor 801 passes The communication bus 803 communicates with the memory 802 for reading executable instructions from the memory 802 to implement:
  • Reading log header information the log header information includes flag information
  • the processor 801 is configured to determine whether to write the log to the flash memory device according to the value of each flag bit in the flag information includes:
  • the log is written to the smallest storage unit corresponding to the flag bit.
  • the processor 801 is configured to write the log in the minimum storage unit corresponding to the flag bit including:
  • the sequence number is the sequence number of the first flag bit whose value is the first preset value.
  • the processor 801 is used to sequentially write logs to the smallest storage unit corresponding to the offset address includes:
  • the processor 801 is used to sequentially write logs to the smallest storage unit corresponding to the offset address and further includes:
  • the log header information is stored in any minimum storage unit in the flash memory device.
  • the processor 801 is configured to determine whether to write the log to the flash memory device according to the value of each flag bit in the flag information includes:
  • the log header information is refreshed.
  • the number of flag bits in the flag bit information is the same as the minimum number of storage units in the flash memory device.
  • each flag bit is one bit long.
  • the log header information further includes a mark length; the mark length is strongly related to the length of each mark bit.
  • the log header information further includes a mark length; the value of the mark length is strongly related to the number of minimum storage units in the flash memory device.
  • the log header information further includes a signature; after a power-on is detected, before determining whether to write the log to the flash memory device according to the value of each flag bit in the flag information, the processor 801 is also used for:
  • the step of determining whether to write the log in the flash memory device according to the value of each flag bit in the flag information is performed.
  • the processor 801 is used to verify the validity of the signature in the log header information includes:
  • the signature is legal; if not, the signature is invalid.
  • a log reading device 900 includes a processor 901 and a memory 902 that stores executable instructions of the processor 901.
  • the processor 901 communicates with the memory 902 through a communication bus 903, and is used to read executable instructions from the memory 902 to implement:
  • Reading log header information the log header information includes flag information
  • the log is sequentially read from the starting minimum storage unit until reaching the starting minimum storage unit.
  • the starting minimum storage unit is a unit whose flag bit value is a first preset value.
  • the starting minimum storage unit is the first unit whose flag bit value is a first preset value if the flag information includes a flag bit whose value is a first preset value.
  • the starting minimum storage unit is the first whose flag bit value is a second preset value Units.
  • An embodiment of the present invention also provides a drone, which includes at least an airframe and a smart battery, a power system, and a flight controller as shown in FIG. 8 provided on the airframe.
  • the smart battery can be The power supply system provides power for the UAV.
  • Embodiments of the present invention also provide a machine-readable storage medium, which stores a number of computer instructions, and when the computer instructions are executed, the steps of the log storage method described in FIGS. 1-7 are implemented.
  • An embodiment of the present invention also provides a machine-readable storage medium, which stores a number of computer instructions, and when the computer instructions are executed, the steps of the log storage method described in FIGS. 1-7 are implemented. Describe the steps of the log reading method.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

一种日志存储方法、日志读取方法、智能电池、无人机。一种日志存储方法,包括:读取日志头信息,所述日志头信息包括标志信息(101);根据所述标志信息中各标志位的取值确定是否将日志写入闪存设备中(102)。通过日志头信息可以确定出存储单元,无需检测每个存储单元,从而可以减少检测时间。另外,无需将需要保存的日志写入原先存储的日志中,从而可以减少数据处理量以及存储日志过程中所占用缓存的大小,降低对资源的需求。

Description

日志存储方法、日志读取方法、智能电池、无人机 技术领域
本发明实施例涉及智能电池技术领域,尤其涉及日志存储方法、日志读取方法、智能电池、无人机。
背景技术
无人机中电池微处理器MCU的存储资源和计算资源有限,需要外接闪存设备FLASH来存储日志信息,以记录电池状态以及定位电池异常等问题。这样,微处理器MCU资源有限与存储日志所消耗资源会发生矛盾,影响到日志存储的效率。
发明内容
本发明实施例提供一种日志存储方法、日志读取方法、智能电池、无人机。
第一方面,本发明实施例提供一种日志存储方法,包括:
读取日志头信息,所述日志头信息包括标志信息;
根据所述标志信息中各标志位的取值确定是否将日志写入闪存设备中。
第二方面,本发明实施例提供一种日志读取方法,包括:
读取日志头信息,所述日志头信息包括标志信息;
根据所述标志信息中各标志位的取值确定闪存设备中起始的最小存储单元;
从所述起始的最小存储单元依次读取日志,直至到达所述起始的最小存储单元。
第三方面,本发明实施例提供一种智能电池,包括处理器和存储所述处理器可执行指令的存储器,所述处理器与所述存储器通信,用于从所述 存储器内读取可执行指令以实现:
读取日志头信息,所述日志头信息包括标志信息;
根据所述标志信息中各标志位的取值确定是否将日志写入闪存设备中。
第四方面,本发明实施例提供一种日志读取设备,包括:
读取日志头信息,所述日志头信息包括标志信息;
根据所述标志信息中各标志位的取值确定闪存设备中起始的最小存储单元;
从所述起始的最小存储单元依次读取日志,直至到达所述起始的最小存储单元。
第五方面,本发明实施例提供一种无人机,至少包括机体和设于所述机体上的如第三方面所述的智能电池、动力系统以及飞行控制器,所述智能电池能够为所述动力系统供电,所述动力系统为所述无人机提供飞行动力。
第六方面,本发明实施例提供一种机器可读存储介质,所述机器可读存储介质上存储有若干计算机指令,所述计算机指令被执行时实现第一方面所述日志存储方法的步骤。
第七方面,本发明实施例提供一种机器可读存储介质,所述机器可读存储介质上存储有若干计算机指令,所述计算机指令被执行时实现第二方面所述日志读取方法的步骤。
由上述的技术方案可见,本实施例中通过设置日志头信息,在有存储日志的需求时,读取日志头信息;然后根据标志信息中的各标志位的取值确定是否将日志写入闪存设备中。例如,在有标志位取值为第一预设值时,将日志写入闪存设备中与标志位相对应的存储单元。又如,在没有标志位取值为第一预设值时,则不存储日志。可见,本实施例中通过日志头信息可以确定出存储单元,无需检测每个存储单元,从而可以减少检测时间。另外,本实施例中无需将需要保存的日志写入原先存储的日志中,从而可 以减少数据处理量以及存储日志过程中所占用缓存的大小,降低对资源的需求。
附图说明
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1是本发明实施例提供的一种日志存储方法的流程示意图;
图2是本发明实施例提供的检验签名合法性的流程示意图;
图3是本发明实施例提供的确定签名是否合法的流程示意图;
图4是本发明实施例提供的根据序号确定最小存储单元的流程示意图;
图5是本发明实施例提供的一种日志读取方法的流程示意图;
图6和图7是本发明实施例提供的一种闪存设备中各最小存储单元以及对应标志位取值的示意图;
图8是本发明实施例提供的一种智能电池的框图;
图9是本发明实施例提供的一种日志读取设备的框图。
具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。另外,在不冲突的情况下,下述的实施例及实施例中的特征可以相互组合。
无人机中电池微处理器MCU的存储资源和计算资源有限,需要外接 闪存设备FLASH来存储日志信息,以记录电池状态以及定位电池异常等问题。这样,微处理器MCU资源有限与存储日志所消耗资源会发生矛盾,影响到日志存储的效率。
为此,本发明实施例提供了一种日志存储方法,其发明构思在于,设置日志头信息,在有存储日志的需求时读取日志头信息,该日志头信息中包括标志信息;然后,根据标志信息中的各标志位的取值可以确定是否将日志写入到闪存设备中。例如,当标志位的取值满足要求时,可以将日志存储到标志位对应的最小存储单元中,该闪存设备包括多个最小存储单元。
需要说明的是,本实施例中最小存储单元是指,每次擦除闪存设备时所能操作的最小,例如4K比特。当然,技术人员还可以根据具体场景调整最小存储单元的大小,相应方案落入本申请的保护范围。
图1是本发明实施例提供的一种日志存储方法的流程示意图,参见图1,可以应用于智能电池、电池管家等电子设备,为方便描述后续以智能电池为例进行说明,一种日志存储方法包括步骤101和步骤102,其中:
101,读取日志头信息,所述日志头信息包括标志信息。
本实施例中,日志头信息可以预先设置,且日志头信息的内容可以根据具体场景具体设置。参见表1,表1示出了本实施例提供的一种日志头信息。
表1,日志头信息
Figure PCTCN2018118654-appb-000001
本实施例中,签名用于日志头信息的合法性校验,通过签名的取值可以确定出签名是否合法,在合法时,闪存设备中存在有效的最小存储单元,此情况下可以将日志存储到有效的最小存储单元;在不合法时,闪存设备中不存在有效的存储单元,此情况下无法将日志存储到闪存设备中。
需要说明的是,签名取值的默认值可以是但不局限于0xAA55。在一些实施例中,在日志写入闪存设备中的一个最小存储单元后,标志位信息取值会发生变化,相应地,签名的默认值也会相应变化。这样,根据签名取值的变化量,或者签名的当前取值与默认值(或者最大取值)可以确定闪存设备中有效的最小存储单元占所有存储单元的比例或数量。
在另一些实施例中,签名仅在闪存设备中所有的最小存储单元都不可用时,其取值才由默认值变为0x FFFF。本实施例签名采用此种方式变化。
在一些实施例中,标志信息中包括多个标志位。标志位可以采用不同的长度,从而表示多个存储单元的有效状态(即可用还是不可用)。
例如,标志位的长度为2位,则可表示4个状态,即00、01、10和11,根据标志位从00到11或者从11到00的变化情况,可以确定对应的各最小存储单元的有效状态。又如,标志位的长度为1位,则可表示2个状态,即0表示最小存储单元不可用,1表示最小存储单元可用。技术人员可以根据具体场景选择标志位的长度,在能够实现本申请方案的情况下,相应方案落入本申请的保护范围。
考虑到闪存设备的一些物理性质:写入操作只能把最小存储单元中数据位从1改为0,擦除操作只能把最小存储单元中数据位从0改为1。本实施例中,标志位的长度采用1位(1比特bit),此场景下标志位可以取值是第一预设值或第二预设值,例如第一预设值为1,第二预设值0,且后续实施例以此取值为例描述方案。另外,标志位的数量与闪存设备中最小存储单元的数量相同,这样标志信息中标志位与闪存设备中最小存储单元是一一对应的关系。
本实施例中,日志头信息还包括标志长度,该标志长度表示标志信息中所有标志位的有效取值范围,该有效取值范围与闪存设备中最小存储单元的数量强相关。例如最小存储单元的数量为4096个,则有效取值范围可以1-4096(或者0-4095)等,可以避免超出有效取值范围判断标志位的取值,减少数据处理量。换言之,该标志长度就是用来说明,在未存储日志 的情况下,闪存设备中有多少个可以存储日志的最小存储单元。
需要说明的是,在有效取值范围的最大值与最小值两者差值和最小存储单元的数量相等的情况下,日志头信息中也可以不设置该标志长度。
在一些实施例中,日志头信息可以包括以下至少一种:签名、标志长度和标志信息。本实施例中,日志头信息可以包括标志信息。需要说明的是,日志头信息的组成可以根据具体场景进行设置,在此不作限定。
在一些实施例,日志头信息可以存储在本地存储器、缓存或者云端,还可以存储在闪存设备中。本实施例中,将日志头信息存储在闪存设备的一个最小存储单元内。该最小存储单元可以为闪存设备内第一个或者最后一个存储单元,从而方便查询、读取和刷新。
本实施例中,智能电池在检测到有日志需要保存时,可以从闪存设备中读取日志头信息,读取时可以将日志头信息全部读取,也可以仅读取标志信息。
在一些实施例中,参见图2,智能电池在检测到重新上电后,将日志写入闪存设备中之前,检测日志头信息中签名的合法性(对应步骤201)。通过判断签名是否合法(对应步骤202),在合法时执行根据所述标志信息中各标志位的取值确定是否将日志写入闪存设备中的步骤(对应步骤203),即执行步骤102;在不合法时,则重新初始化日志头信息,并继续执行读取日志头信息的步骤(对应步骤204),即执行步骤102。
需要说明的是,本实施例中,步骤203和步骤204的顺序不分先后,包括以下至少一种:步骤203先于步骤204执行,步骤204先于步骤203执行,步骤203和步骤204同时执行。
本实施例中,智能电池校验日志头信息中签名的合法性可以包括:参见图3,智能电池获取日志信息中签名的当前值(对应步骤301)。然后。智能电池对比当前值和预设值(即默认值)(对应步骤302),在当前值和预设值相等时,智能电池确定签名合法(对应步骤303),在当前值和预设值不等时,智能电池确定签名不合法(对应步骤304)。本实施例中, 通过确定日志头信息是否合法,
102,根据所述标志信息中各标志位的取值确定是否将日志写入闪存设备中。
在读取到标志信息后,智能电池可以获取标志信息中各标志位的取值。获取方式可以包括:
方式一,智能电池可以随机读取各标志位的取值,然后,从中选择一个取值为第一预设值的标志位。
方式二,智能电池可以按照标志位的顺序依次读取各标志位的取值。然后,从中选择一个取值为第一预设值的标志位。
方式三,智能电池可以按照随机或者依次读取各标志位取值的方式,若标志位的取值为第二预设值,则继续读取标志位,直至读取到一个标志位的取值为第一预设值为止。
考虑到闪存设备中各存储单元的擦写次数有限,因此对各存储单元擦写次数作均衡处理,即本实施例中采用依次向各最小存储单元存储日志的方法来达到擦写次数均衡的效果。换言之,本实施例中,采用方式三获取标志位的取值。
本实施例中,智能电池检测到标志信息中包含取值为第一预设值的标志位时,将需要保存的日志写入标志位对应的最小存储单元中。其中,确定最小存储单元的位置可以包括:参见图4,智能电池在检测到取值为第一预设值的标志位时,可以确定标志位的序号(对应步骤401)。在一些场景中,该序号为取值为第一预设值的第一个标志位的序号。然后,智能电池基于序号和偏移地址的关系,根据标志位的序号获取闪存设备中标志位对应的最小存储单元的偏移地址(对应步骤402)。最后,智能设备将日志依次写入偏移地址对应的最小存储单元中(对应步骤403)。这样,本实施例中将日志依次写入各最小存储单元,从而保证各最小存储单元的擦写次数保持相同(或者相近),达到擦写均衡的效果,延长闪存设备的使用寿命。
实际应用中,每个最小存储单元的大小是固定的,例如4K字节。并且,闪存设备中第一个存储单元的物理地址(即首地址)也是固定的,因此根据每个最小存储单元的大小和序号可以确定出序号和偏移地址的关系。例如,第一个存储单元的物理地址为0x00FF,序号为2,则可以得到第2个最小存储单元的偏移地址为2*4K字节。然后,智能电池再结合第一个存储单元的物理地址即可得到第2个最小存储单元的物理地址。为方便查阅,可以预先把序号和偏移地址建立表格,存储在缓存、本地存储器或者云端等位置。
本实施例中,考虑到闪存设备的物理性质,智能设备将日志写入最小存储单元之前,先对最小存储单元进行擦除操作,然后再将日志写入擦除操作后的最小存储单元中。另外,智能设置在擦除最小存储单元之前、之后或者同时,还将其对应的标志位的取值从第一预设值修改为第二预设值,使最小存储单元的状态从“可用”变为“不可用”。
在一些应用场景中,日志的长度可以调整。本实施例中以128字节的日志为例进行说明。表1示出了日志格式,表2是日志中各部分内容的说明
表1日志格式
Figure PCTCN2018118654-appb-000002
表2日志中各部分内容的说明
内容 说明
Log_item 统一格式的日志记录单元,固定长度128字节
Log_set 日志类型
Log_id 日志子类型
Sys_sec 系统时间
UTC 当前飞控同步到智能电池的UTC时间
Data 日志数据段,由日志类型和子类型决定具体字段含义
Crc8 日志记录单元前127字节的crc8检验值
智能电池每次将一个128字节的日志写入到最小存储单元中,直至最小存储单元内存满日志。之后,智能电池获取下一个取值为第一预设值的标志位,起始位置可以是全部标志位的第一个标志位,还可以是刚存满日志的最小存储单元对应的标志位,然后返回步骤101。
本实施例中,智能设备在检测完标志信息中的全部标志位后,若标志信息不包含取值为第一预设值的标志位,即全部标志位取值为第二预设值时,则刷新日志头信息。
需要说明的是,本实施例中刷新日志头信息,不仅刷新签名,还刷新标志信息。以刷新标志信息为例,将标志信息中所有标志位的取值从第二预设值调整为第一预设值。刷新日志头信息后,表明闪存设备的全部最小存储单元为“可用”状态,换言之,全部最小存储单元经过一次擦写操作,使各最小存储单元具有相同(或相近)的擦写次数,达到均衡擦写次数的效果。
至此,本实施例中通过设置日志头信息,在有存储日志的需求时,读取日志头信息;然后根据标志信息中的各标志位的取值确定是否将日志写入闪存设备中。例如,在有标志位取值为第一预设值时,将日志写入闪存设备中与标志位相对应的存储单元。又如,在没有标志位取值为第一预设值时,则不存储日志。可见,本实施例中通过日志头信息可以确定出存储单元,无需检测每个存储单元,从而可以减少检测时间。另外,本实施例中无需将需要保存的日志写入原先存储的日志中,从而可以减少数据处理量以及存储日志过程中所占用缓存的大小,降低对资源的需求。
基于上述日志存储方法将日志存储到闪存设备后,本发明实施例还提供了一种日志读取方法,图5是本发明实施例提供的一种日志读取方法的流程示意图,可以应用于日志读取设备。其中日志读取设备可以为移动终端、智能电池、读取卡、平板电脑、个人计算机等电子设备,后续继续以智能电池为例进行描述。参见图5,一种日志读取方法,包括步骤501~步骤503,其中:
501,读取日志头信息,所述日志头信息包括标志信息。
步骤501和步骤101的具体方法和原理一致,详细描述请参考图1及步骤101的相关内容,此处不再赘述。
502,根据所述标志信息中各标志位的取值确定闪存设备中起始的最小存储单元。
本实施例中,智能电池获取标志信息中各标志位的取值,得到取值为第一预设值的第一个标志位,将该第一个标志位对应的最小存储单元作为读取日志的起始的最小存储单元。
需要说明的是,本实施例中智能设备获取各标志位的取值以及起始的最小存储单元,可以采用图1和步骤102中方式三的相关内容,在此不再赘述。
当然,智能电池还可以获取标志信息中各标志位的取值,得到取值为第一预设值的标志位,将其中一个标志位对应的最小存储单元作为读取日志的起始的最小存储单元,同样可以实现本申请的方案,在此不再赘述。
在另一实施例中,智能电池检测到标志信息不包含取值为第一预设值的标志位,即全部标志位取值均为第二预设值,则智能电池确定起始的最小存储单元是标志位的取值为第二预设值的第一个单元。
503,从所述起始的最小存储单元依次读取日志,直至到达所述起始的最小存储单元。
本实施例中,智能电池从起始的最小存储单元依次读取闪存设备中存储的日志,在读取到最后一个存储单元后返回闪存设备的第一最小存储单元继续读取日志,直至到达之前确定出的起始的最小存储单元。也就是说,智能电池从起始的最小存储单元依次读过闪存设备中的每个最小存储单元,从而得到全部日志。
可理解的是,由于标志位取值为第一预设值时对应的最小存储单元未存入新的日志,而取值为第二预设值的最小存储单元已经存入最新的日志,因此,按照上述方式读取日志为从旧到新的日志。当读取方向变化时,起 始的最小存储单元为取值为第二预设值且与取值为第一预设值的第一个标志位最近的标志位对应的最小存储单元,此情况下,可以读取到从新到旧的日志。
图6是本发明实施例提供的一种闪存设备中各最小存储单元以及对应标志位取值的示意图,参见图6,智能电池确定取值为第一预设值的标志位是第3行第3列的标志位,然后读取最小存储单元顺序,以(行,列)表示各最小存储单元的位置,如下:
(3,3)、(3,4)、(3,5);
(4,1)、(4,2)、(4,3)、(4,4)、(4,5);
(5,1)、(5,2)、(5,3)、(5,4)、(5,5);
(1,1)、(1,2)、(1,3)、(1,4)、(1,5);
(2,1)、(2,2)、(2,3)、(2,4)、(2,5);
(3,1)、(3,2)、 (3,3)
需要说明的是,最后一个 (3,3)采用不同字体区别其他最小存储单元,表示回到起始的最小存储单元,不再读取数据。
这样,智能电池可以读完闪存设备中所存储的所有日志,且日志时间为从旧到新。
在另一实施例中,智能电池还可以反方向读取各最小存储单元中存储的日志,读取顺序为:
(3,2)、(3,1);
(2,5)、(2,4)、(2,3)、(2,2)、(2,1);
(1,5)、(1,4)、(1,3)、(1,2)、(1,1);
(5,5)、(5,4)、(5,3)、(5,2)、(5,1);
(4,5)、(4,4)、(4,3)、(4,2)、(4,1);
(3,5)、(3,4)、(3,3)、 (3,2)
这样,智能电池可以读完闪存设备中所存储的所有日志,且日志时间为从新到旧。
在又一实施例中,智能电池检测到标志信息不包含取值为第一预设值的标志位,即全部标志位取值均为第二预设值,则智能电池确定起始的最小存储单元是标志位的取值为第二预设值的第一个单元。
图7是本发明实施例提供的一种闪存设备中各最小存储单元以及对应标志位取值的示意图,参见图7,智能电池读取各最小存储单元中存储的日志,读取顺序为:
(1,1)、(1,2)、(1,3)、(1,4)、(1,5);
(2,1)、(2,2)、(2,3)、(2,4)、(2,5);
(3,1)、(3,2)、(3,3)、(3,4)、(3,5);
(4,1)、(4,2)、(4,3)、(4,4)、(4,5);
(5,1)、(5,2)、(5,3)、(5,4)、(5,5)。
这样,智能电池可以读完闪存设备中所存储的所有日志,且日志时间为从旧到新。
至此,本实施例中通过日志头信息可以确定出起始的最小存储单元,然后读取到从旧到新或者从新到旧的全部日志,提高读取效率。
图8是本发明实施例提供的一种智能电池的框图,参见图8,一种智能电池800,包括处理器801和存储所述处理器801可执行指令的存储器802,所述处理器801通过通信总线803与所述存储器802通信,用于从所述存储器802内读取可执行指令以实现:
读取日志头信息,所述日志头信息包括标志信息;
根据所述标志信息中各标志位的取值确定是否将日志写入闪存设备中。
在一些实施例中,所述处理器801用于根据所述标志信息中各标志位的取值确定是否将日志写入闪存设备中包括:
若所述标志信息中包含取值为第一预设值的标志位,则将日志写入所述标志位对应的最小存储单元中。
在一些实施例中,所述处理器801用于将日志写入所述标志位对应的 最小存储单元中包括:
确定所述标志位的序号;
基于序号和偏移地址的关系,根据所述标志位的序号获取闪存设备中最小存储单元的偏移地址;
将日志依次写入所述偏移地址对应的最小存储单元中。
在一些实施例中,所述序号是取值为第一预设值的第一个标志位的序号。
在一些实施例中,所述处理器801用于将日志依次写入所述偏移地址对应的最小存储单元中包括:
对所述最小存储单元进行擦除操作;
将所述日志写入擦除操作后的最小存储单元中。
在一些实施例中,所述处理器801器用于将日志依次写入所述偏移地址对应的最小存储单元中还包括:
将所述标志位的取值从所述第一预设值修改为第二预设值。
在一些实施例中,所述日志头信息存储在闪存设备中任意一个最小存储单元内。
在一些实施例中,所述处理器801用于根据所述标志信息中各标志位的取值确定是否将日志写入闪存设备中包括:
若所述标志信息中所有标志位取值为第二预设值,则刷新所述日志头信息。
在一些实施例中,所述标志位信息中标志位的数量与闪存设备中最小存储单元数量相同。
在一些实施例中,每个标志位长度为一比特bit。
在一些实施例中,所述日志头信息还包括标志长度;所述标志长度与每个标志位长度强相关。
在一些实施例中,所述日志头信息还包括标志长度;所述标志长度的数值与闪存设备中最小存储单元的数量强相关。
在一些实施例中,所述日志头信息还包括签名;在检测到重新上电后,根据所述标志信息中各标志位的取值确定是否将日志写入闪存设备中之前,所述处理器801还用于:
校验日志头信息中签名的合法性;
若不合法,则重新初始化所述日志头信息,并继续执行读取日志头信息的步骤;
若合法,则执行根据所述标志信息中各标志位的取值确定是否将日志写入闪存设备中的步骤。
在一些实施例中,所述处理器801用于校验日志头信息中签名的合法性包括:
获取日志头信息中签名的当前值;
对比所述当前值和预设值;
若所述当前值和所述预设值相等,则所述签名合法;若不等,则所述签名不合法。
图9是本发明实施例提供的一种智能电池的框图,参见图9,一种日志读取设备900,包括处理器901和存储所述处理器901可执行指令的存储器902,所述处理器901通过通信总线903与所述存储器902通信,用于从所述存储器902内读取可执行指令以实现:
读取日志头信息,所述日志头信息包括标志信息;
根据所述标志信息中各标志位的取值确定闪存设备中起始的最小存储单元;
从所述起始的最小存储单元依次读取日志,直至到达所述起始的最小存储单元。
在一些实施例中,若所述标志信息包含取值为第一预设值的标志位,则所述起始的最小存储单元是其标志位取值为第一预设值的单元。
在一些实施例中,若所述标志信息包含取值为第一预设值的标志位,则所述起始的最小存储单元是其标志位取值为第一预设值的第一个单元。
在一些实施例中,若所述标志信息不包含取值为第一预设值的标志位,则所述起始的最小存储单元是其标志位的取值为第二预设值的第一个单元。
本发明实施例还提供了一种无人机,至少包括机体和设于所述机体上的如图8所示所述的智能电池、动力系统以及飞行控制器,所述智能电池能够为所述动力系统供电,所述动力系统为所述无人机提供飞行动力。
本发明实施例还提供了一种机器可读存储介质,所述机器可读存储介质上存储有若干计算机指令,所述计算机指令被执行时实现图1~图7所述日志存储方法的步骤。
本发明实施例还提供了一种机器可读存储介质,所述机器可读存储介质上存储有若干计算机指令,所述计算机指令被执行时实现图1~图7所述日志存储方法的步骤所述日志读取方法的步骤。
需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。
以上对本发明实施例所提供的检测装置和方法进行了详细介绍,本发明中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本发明的限制。

Claims (39)

  1. 一种日志存储方法,其特征在于,包括:
    读取日志头信息,所述日志头信息包括标志信息;
    根据所述标志信息中各标志位的取值确定是否将日志写入闪存设备中。
  2. 根据权利要求1所述的日志存储方法,其特征在于,根据所述标志信息中各标志位的取值确定是否将日志写入闪存设备中包括:
    若所述标志信息中包含取值为第一预设值的标志位,则将日志写入所述标志位对应的最小存储单元中。
  3. 根据权利要求2所述的日志存储方法,其特征在于,将日志写入所述标志位对应的最小存储单元中包括:
    确定所述标志位的序号;
    基于序号和偏移地址的关系,根据所述标志位的序号获取闪存设备中最小存储单元的偏移地址;
    将日志依次写入所述偏移地址对应的最小存储单元中。
  4. 根据权利要求3所述的日志存储方法,其特征在于,所述序号是取值为第一预设值的第一个标志位的序号。
  5. 根据权利要求3所述的日志存储方法,其特征在于,将日志依次写入所述偏移地址对应的最小存储单元中包括:
    对所述最小存储单元进行擦除操作;
    将所述日志写入擦除操作后的最小存储单元中。
  6. 根据权利要求5所述的日志存储方法,其特征在于,将日志依次写入所述偏移地址对应的最小存储单元中还包括:
    将所述标志位的取值从所述第一预设值修改为第二预设值。
  7. 根据权利要求1所述的日志存储方法,其特征在于,所述日志头信息存储在闪存设备中任意一个最小存储单元内。
  8. 根据权利要求1所述的日志存储方法,其特征在于,根据所述标志信息中各标志位的取值确定是否将日志写入闪存设备中包括:
    若所述标志信息中所有标志位取值为第二预设值,则刷新所述日志头信息。
  9. 根据权利要求1所述的日志存储方法,其特征在于,所述标志位信息中标志位的数量与闪存设备中最小存储单元数量相同。
  10. 根据权利要求9所述的日志存储方法,其特征在于,每个标志位长度为一比特bit。
  11. 根据权利要求1所述的日志存储方法,其特征在于,所述日志头信息还包括标志长度;所述标志长度与每个标志位长度强相关。
  12. 根据权利要求1所述的日志存储方法,其特征在于,所述日志头信息还包括标志长度;所述标志长度的数值与闪存设备中最小存储单元的数量强相关。
  13. 根据权利要求1所述的日志存储方法,其特征在于,所述日志头信息还包括签名;在检测到重新上电后,根据所述标志信息中各标志位的取值确定是否将日志写入闪存设备中之前,所述方法还包括:
    校验日志头信息中签名的合法性;
    若不合法,则重新初始化所述日志头信息,并继续执行读取日志头信息的步骤;
    若合法,则执行根据所述标志信息中各标志位的取值确定是否将日志写入闪存设备中的步骤。
  14. 根据权利要求13所述的日志存储方法,其特征在于,校验日志头信息中签名的合法性包括:
    获取日志头信息中签名的当前值;
    对比所述当前值和预设值;
    若所述当前值和所述预设值相等,则所述签名合法;若不等,则所述签名不合法。
  15. 一种日志读取方法,其特征在于,包括:
    读取日志头信息,所述日志头信息包括标志信息;
    根据所述标志信息中各标志位的取值确定闪存设备中起始的最小存储单元;
    从所述起始的最小存储单元依次读取日志,直至到达所述起始的最小存储单元。
  16. 根据权利要求15所述的日志读取方法,其特征在于,若所述标志信息包含取值为第一预设值的标志位,则所述起始的最小存储单元是其标志位取值为第一预设值的单元。
  17. 根据权利要求15所述的日志读取方法,其特征在于,若所述标志信息包含取值为第一预设值的标志位,则所述起始的最小存储单元是其标志位取值为第一预设值的第一个单元。
  18. 根据权利要求15所述的日志读取方法,其特征在于,若所述标志信息不包含取值为第一预设值的标志位,则所述起始的最小存储单元是其标志位的取值为第二预设值的第一个单元。
  19. 一种智能电池,其特征在于,包括处理器和存储所述处理器可执行指令的存储器,所述处理器与所述存储器通信,用于从所述存储器内读取可执行指令以实现:
    读取日志头信息,所述日志头信息包括标志信息;
    根据所述标志信息中各标志位的取值确定是否将日志写入闪存设备中。
  20. 根据权利要求19所述的智能电池,其特征在于,所述处理器用于根据所述标志信息中各标志位的取值确定是否将日志写入闪存设备中包括:
    若所述标志信息中包含取值为第一预设值的标志位,则将日志写入所述标志位对应的最小存储单元中。
  21. 根据权利要求20所述的智能电池,其特征在于,所述处理器用于 将日志写入所述标志位对应的最小存储单元中包括:
    确定所述标志位的序号;
    基于序号和偏移地址的关系,根据所述标志位的序号获取闪存设备中最小存储单元的偏移地址;
    将日志依次写入所述偏移地址对应的最小存储单元中。
  22. 根据权利要求21所述的智能电池,其特征在于,所述序号是取值为第一预设值的第一个标志位的序号。
  23. 根据权利要求21所述的智能电池,其特征在于,所述处理器用于将日志依次写入所述偏移地址对应的最小存储单元中包括:
    对所述最小存储单元进行擦除操作;
    将所述日志写入擦除操作后的最小存储单元中。
  24. 根据权利要求23所述的智能电池,其特征在于,所述处理器用于将日志依次写入所述偏移地址对应的最小存储单元中还包括:
    将所述标志位的取值从所述第一预设值修改为第二预设值。
  25. 根据权利要求19所述的智能电池,其特征在于,所述日志头信息存储在闪存设备中任意一个最小存储单元内。
  26. 根据权利要求19所述的智能电池,其特征在于,所述处理器用于根据所述标志信息中各标志位的取值确定是否将日志写入闪存设备中包括:
    若所述标志信息中所有标志位取值为第二预设值,则刷新所述日志头信息。
  27. 根据权利要求19所述的智能电池,其特征在于,所述标志位信息中标志位的数量与闪存设备中最小存储单元数量相同。
  28. 根据权利要求27所述的智能电池,其特征在于,每个标志位长度为一比特bit。
  29. 根据权利要求19所述的智能电池,其特征在于,所述日志头信息还包括标志长度;所述标志长度与每个标志位长度强相关。
  30. 根据权利要求19所述的智能电池,其特征在于,所述日志头信息还包括标志长度;所述标志长度的数值与闪存设备中最小存储单元的数量强相关。
  31. 根据权利要求19所述的智能电池,其特征在于,所述日志头信息还包括签名;在检测到重新上电后,根据所述标志信息中各标志位的取值确定是否将日志写入闪存设备中之前,所述处理器还用于:
    校验日志头信息中签名的合法性;
    若不合法,则重新初始化所述日志头信息,并继续执行读取日志头信息的步骤;
    若合法,则执行根据所述标志信息中各标志位的取值确定是否将日志写入闪存设备中的步骤。
  32. 根据权利要求31所述的智能电池,其特征在于,所述处理器用于校验日志头信息中签名的合法性包括:
    获取日志头信息中签名的当前值;
    对比所述当前值和预设值;
    若所述当前值和所述预设值相等,则所述签名合法;若不等,则所述签名不合法。
  33. 一种日志读取设备,其特征在于,包括处理器和存储所述处理器可执行指令的存储器,所述处理器与所述存储器通信,用于从所述存储器内读取可执行指令以实现:
    读取日志头信息,所述日志头信息包括标志信息;
    根据所述标志信息中各标志位的取值确定闪存设备中起始的最小存储单元;
    从所述起始的最小存储单元依次读取日志,直至到达所述起始的最小存储单元。
  34. 根据权利要求33所述的日志读取设备,其特征在于,若所述标志信息包含取值为第一预设值的标志位,则所述起始的最小存储单元是其标 志位取值为第一预设值的单元。
  35. 根据权利要求33所述的日志读取设备,其特征在于,若所述标志信息包含取值为第一预设值的标志位,则所述起始的最小存储单元是其标志位取值为第一预设值的第一个单元。
  36. 根据权利要求33所述的日志读取设备,其特征在于,若所述标志信息不包含取值为第一预设值的标志位,则所述起始的最小存储单元是其标志位的取值为第二预设值的第一个单元。
  37. 一种无人机,其特征在于,至少包括机体和设于所述机体上的如权利要求19~32任一项所述的智能电池、动力系统以及飞行控制器,所述智能电池能够为所述动力系统供电,所述动力系统为所述无人机提供飞行动力。
  38. 一种机器可读存储介质,其特征在于,所述机器可读存储介质上存储有若干计算机指令,所述计算机指令被执行时实现权利要求1~15任一项所述日志存储方法的步骤。
  39. 一种机器可读存储介质,其特征在于,所述机器可读存储介质上存储有若干计算机指令,所述计算机指令被执行时实现权利要求16~18任一项所述日志读取方法的步骤。
PCT/CN2018/118654 2018-11-30 2018-11-30 日志存储方法、日志读取方法、智能电池、无人机 WO2020107430A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2018/118654 WO2020107430A1 (zh) 2018-11-30 2018-11-30 日志存储方法、日志读取方法、智能电池、无人机
CN201880069257.9A CN111433765A (zh) 2018-11-30 2018-11-30 日志存储方法、日志读取方法、智能电池、无人机

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2018/118654 WO2020107430A1 (zh) 2018-11-30 2018-11-30 日志存储方法、日志读取方法、智能电池、无人机

Publications (1)

Publication Number Publication Date
WO2020107430A1 true WO2020107430A1 (zh) 2020-06-04

Family

ID=70854261

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/118654 WO2020107430A1 (zh) 2018-11-30 2018-11-30 日志存储方法、日志读取方法、智能电池、无人机

Country Status (2)

Country Link
CN (1) CN111433765A (zh)
WO (1) WO2020107430A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112992066B (zh) * 2021-04-26 2021-09-07 北京集创北方科技股份有限公司 显示数据存取方法及其控制电路、显示器和资讯处理装置

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102567184A (zh) * 2011-12-27 2012-07-11 青岛海信宽带多媒体技术有限公司 一种基于Flash的日志存储方法
CN106033322A (zh) * 2015-03-17 2016-10-19 北京元心科技有限公司 一种数据存储方法及装置
WO2017129960A1 (en) * 2016-01-25 2017-08-03 Above Surveying Ltd. Utilising uavs for detecting defects in solar panel arrays
CN107291892A (zh) * 2017-06-21 2017-10-24 郑州云海信息技术有限公司 一种记录日志的方法和装置
CN108829345A (zh) * 2018-05-25 2018-11-16 华为技术有限公司 日志文件的数据处理方法和终端设备
CN108875075A (zh) * 2018-07-09 2018-11-23 深圳市道通智能航空技术有限公司 无人机系统日志的存储方法及无人机图传系统

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100498797C (zh) * 2002-12-23 2009-06-10 西门子能量及自动化公司 利用plc的存储设备的方法
WO2006064498A2 (en) * 2004-12-16 2006-06-22 Ramot At Tel-Aviv University Ltd. Transactional flash file system for microcontrollers and embedded systems
CN100464315C (zh) * 2006-05-22 2009-02-25 中国软件与技术服务股份有限公司 移动存储器失泄密防护的方法和系统
US7979626B2 (en) * 2008-05-13 2011-07-12 Microsoft Corporation Flash recovery employing transaction log
JP5087502B2 (ja) * 2008-09-03 2012-12-05 株式会社エヌ・ティ・ティ・ドコモ 操作ログ管理装置及び操作ログ管理方法
WO2015096698A1 (zh) * 2013-12-24 2015-07-02 飞天诚信科技股份有限公司 一种Flash的数据写入和读取方法
CN106408790B (zh) * 2016-08-26 2024-03-19 恒银金融科技股份有限公司 金融设备循环机芯日志信息写入方法及读取方法
CN106951521B (zh) * 2017-03-20 2020-09-15 Oppo广东移动通信有限公司 日志文件的读写方法、装置及系统
CN108829342B (zh) * 2018-05-09 2021-06-25 青岛海信宽带多媒体技术有限公司 一种日志存储方法、系统及存储装置

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102567184A (zh) * 2011-12-27 2012-07-11 青岛海信宽带多媒体技术有限公司 一种基于Flash的日志存储方法
CN106033322A (zh) * 2015-03-17 2016-10-19 北京元心科技有限公司 一种数据存储方法及装置
WO2017129960A1 (en) * 2016-01-25 2017-08-03 Above Surveying Ltd. Utilising uavs for detecting defects in solar panel arrays
CN107291892A (zh) * 2017-06-21 2017-10-24 郑州云海信息技术有限公司 一种记录日志的方法和装置
CN108829345A (zh) * 2018-05-25 2018-11-16 华为技术有限公司 日志文件的数据处理方法和终端设备
CN108875075A (zh) * 2018-07-09 2018-11-23 深圳市道通智能航空技术有限公司 无人机系统日志的存储方法及无人机图传系统

Also Published As

Publication number Publication date
CN111433765A (zh) 2020-07-17

Similar Documents

Publication Publication Date Title
US8006030B2 (en) Memory controller for identifying the last valid page/segment in a physical block of a flash memory
US10810144B2 (en) System and method for operating a DRR-compatible asynchronous memory module
US10976932B2 (en) Method for providing a client device access to a plurality of remote storage devices
US9026888B2 (en) Method, system and apparatus for providing access to error correction information
US9639461B2 (en) System and method of processing of duplicate data at a data storage device
US8412881B2 (en) Modified B+ tree to store NAND memory indirection maps
US9766974B2 (en) Data storage device and data access-method
US10235300B2 (en) Memory system including memory device and operation method thereof
JP2014142931A5 (zh)
US9417959B2 (en) Flash device and operating method thereof
US20080162782A1 (en) Using Transacted Writes and Caching Mechanism to Improve Write Performance in Multi-Level Cell Flash Memory
US10152274B2 (en) Method and apparatus for reading/writing data from/into flash memory, and user equipment
US8868793B2 (en) SAS expander system and method for dynamically allocating SAS addresses to SAS expander devices
US20220138096A1 (en) Memory system
US20220075556A1 (en) Memory systems including examples of calculating hamming distances for neural network and data center applications
TWI528372B (zh) 資料儲存裝置以及揮發式記憶體的資料校驗方法
US20130159604A1 (en) Memory storage device and memory controller and data writing method thereof
WO2016173470A1 (zh) 一种基于嵌入式多媒体卡eMMC的存储方法及系统
US9304686B2 (en) Data storage device and data trimming method
WO2020107430A1 (zh) 日志存储方法、日志读取方法、智能电池、无人机
US20180181476A1 (en) Bad page management in storage devices
CN107678977B (zh) 一种计数器的读写方法及装置
TWI512475B (zh) 有助於在記憶體模組和中央處理器之間進行通信的方法及相關機器可讀儲存媒體
CN111737161B (zh) Flash存储器的文件传输方法、终端及存储介质
US9009571B2 (en) Storage medium, system and method utilizing the same

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18941783

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18941783

Country of ref document: EP

Kind code of ref document: A1