Kaynağa Gözat

nvs_partition_generator: Strip trailing whitespace in "hex2bin" input files

Angus Gratton 5 yıl önce
ebeveyn
işleme
a7ae0ee1fa

+ 5 - 2
components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py

@@ -360,10 +360,12 @@ class Page(object):
 
         if datalen > Page.PAGE_PARAMS["max_old_blob_size"]:
             if self.version == Page.VERSION1:
-                raise InputError(" Input File: Size exceeds max allowed length `%s` bytes for key `%s`." % (Page.PAGE_PARAMS["max_old_blob_size"], key))
+                raise InputError(" Input File: Size (%d) exceeds max allowed length `%s` bytes for key `%s`."
+                                 % (datalen, Page.PAGE_PARAMS["max_old_blob_size"], key))
             else:
                 if encoding == "string":
-                    raise InputError(" Input File: Size exceeds max allowed length `%s` bytes for key `%s`." % (Page.PAGE_PARAMS["max_old_blob_size"], key))
+                    raise InputError(" Input File: Size (%d) exceeds max allowed length `%s` bytes for key `%s`."
+                                     % (datalen, Page.PAGE_PARAMS["max_old_blob_size"], key))
 
         # Calculate no. of entries data will require
         rounded_size = (datalen + 31) & ~31
@@ -544,6 +546,7 @@ class NVS(object):
     """
     def write_entry(self, key, value, encoding):
         if encoding == "hex2bin":
+            value = value.strip()
             if len(value) % 2 != 0:
                 raise InputError("%s: Invalid data length. Should be multiple of 2." % key)
             value = binascii.a2b_hex(value)