kopia lustrzana https://github.com/espressif/esp-idf
Merge branch 'feature/nvs_support_data_encodings' into 'master'
Feature/nvs support data encodings See merge request espressif/esp-idf!7557pull/4772/head
commit
a70a6f8974
|
@ -29,9 +29,10 @@ Each line of a .csv file should contain 4 parameters, separated by a comma. The
|
|||
+-----+-----------+----------------------------------------------------------------------+-----------------------------------------------------+
|
||||
| 2 | Type | Supported values are ``file``, ``data`` and ``namespace``. | |
|
||||
+-----+-----------+----------------------------------------------------------------------+-----------------------------------------------------+
|
||||
| 3 | Encoding | Supported values are: ``u8``, ``i8``, ``u16``, ``u32``, | As of now, for the ``file`` type, |
|
||||
| | | ``i32``, ``string``, ``hex2bin``, ``base64`` and ``binary``. | only ``hex2bin``, ``base64``, ``string``, |
|
||||
| | | This specifies how actual data values are encoded in the | and ``binary`` encoding is supported. |
|
||||
| 3 | Encoding | Supported values are: ``u8``, ``i8``, ``u16``, ``i16``, ``u32``, | As of now, for the ``file`` type, |
|
||||
| | | ``i32``, ``u64``, ``i64``, ``string``, ``hex2bin``, ``base64`` | only ``hex2bin``, ``base64``, ``string``, |
|
||||
| | | and ``binary``. | and ``binary`` encoding is supported. |
|
||||
| | | This specifies how actual data values are encoded in the | |
|
||||
| | | resulting binary file. The difference between the ``string`` | |
|
||||
| | | and ``binary`` encoding is that ``string`` data is terminated | |
|
||||
| | | with a NULL character, whereas ``binary`` data is not. | |
|
||||
|
|
|
@ -75,6 +75,8 @@ class Page(object):
|
|||
I16 = 0x12
|
||||
U32 = 0x04
|
||||
I32 = 0x14
|
||||
U64 = 0x08
|
||||
I64 = 0x18
|
||||
SZ = 0x21
|
||||
BLOB = 0x41
|
||||
BLOB_DATA = 0x42
|
||||
|
@ -432,12 +434,21 @@ class Page(object):
|
|||
elif encoding == "u16":
|
||||
entry_struct[1] = Page.U16
|
||||
struct.pack_into('<H', entry_struct, 24, data)
|
||||
elif encoding == "i16":
|
||||
entry_struct[1] = Page.I16
|
||||
struct.pack_into('<h', entry_struct, 24, data)
|
||||
elif encoding == "u32":
|
||||
entry_struct[1] = Page.U32
|
||||
struct.pack_into('<I', entry_struct, 24, data)
|
||||
elif encoding == "i32":
|
||||
entry_struct[1] = Page.I32
|
||||
struct.pack_into('<i', entry_struct, 24, data)
|
||||
elif encoding == "u64":
|
||||
entry_struct[1] = Page.U64
|
||||
struct.pack_into('<Q', entry_struct, 24, data)
|
||||
elif encoding == "i64":
|
||||
entry_struct[1] = Page.I64
|
||||
struct.pack_into('<q', entry_struct, 24, data)
|
||||
|
||||
# Compute CRC
|
||||
crc_data = bytearray(b'28')
|
||||
|
@ -547,7 +558,7 @@ class NVS(object):
|
|||
|
||||
encoding = encoding.lower()
|
||||
varlen_encodings = ["string", "binary", "hex2bin", "base64"]
|
||||
primitive_encodings = ["u8", "i8", "u16", "u32", "i32"]
|
||||
primitive_encodings = ["u8", "i8", "u16", "i16", "u32", "i32", "u64", "i64"]
|
||||
|
||||
if encoding in varlen_encodings:
|
||||
try:
|
||||
|
@ -615,7 +626,7 @@ def write_entry(nvs_instance, key, datatype, encoding, value):
|
|||
:param nvs_instance: Instance of an NVS class returned by nvs_open()
|
||||
:param key: Key of the data
|
||||
:param datatype: Data type. Valid values are "file", "data" and "namespace"
|
||||
:param encoding: Data encoding. Valid values are "u8", "i8", "u16", "u32", "i32", "string", "binary", "hex2bin" and "base64"
|
||||
:param encoding: Data encoding. Valid values are "u8", "i8", "u16", "i16", "u32", "i32", "u64", "i64", "string", "binary", "hex2bin" and "base64"
|
||||
:param value: Data value in ascii encoded string format for "data" datatype and filepath for "file" datatype
|
||||
:return: None
|
||||
"""
|
||||
|
|
Ładowanie…
Reference in New Issue