aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/python/usrp_mpm/test_bfrfs.py
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-10-09 17:03:29 -0700
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:04:02 -0800
commit221805d8b15bd70dbe4528a91e1f955b8e43f36e (patch)
tree88948efdd7abcf88ba3e351407a32eae15415228 /mpm/python/usrp_mpm/test_bfrfs.py
parent35dc86aaa5c880641b80f494f044f21963207dbc (diff)
downloaduhd-221805d8b15bd70dbe4528a91e1f955b8e43f36e.tar.gz
uhd-221805d8b15bd70dbe4528a91e1f955b8e43f36e.tar.bz2
uhd-221805d8b15bd70dbe4528a91e1f955b8e43f36e.zip
mpm: Add BufferFS serialization library
BufferFS is a serialization format with CRC checking and optional byte-alignment for records. It allows storing arbitrary blobs, together with a 8-character identifier, in a contiguous buffer that supports random access. This is suitable for storing arbitrary blobs in EEPROM, but could also support other things. Signed-off-by: Martin Braun <martin.braun@ettus.com>
Diffstat (limited to 'mpm/python/usrp_mpm/test_bfrfs.py')
-rw-r--r--mpm/python/usrp_mpm/test_bfrfs.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/mpm/python/usrp_mpm/test_bfrfs.py b/mpm/python/usrp_mpm/test_bfrfs.py
new file mode 100644
index 000000000..03312f51f
--- /dev/null
+++ b/mpm/python/usrp_mpm/test_bfrfs.py
@@ -0,0 +1,25 @@
+import mpmlog
+import bfrfs
+
+LOG = mpmlog.get_main_logger().getChild('log')
+B0 = bfrfs.BufferFS(b'', 256, 16, log=LOG)
+
+B0.set_blob('foo', b'123123123')
+B0.set_blob('baz', b'abcdabcdasdfasdf')
+
+print(B0.buffer)
+print(len(B0.buffer))
+
+LOG.warn('next foo')
+
+
+new_buf = open('eeprom.dat', 'rb').read()
+B1 = bfrfs.BufferFS(new_buf, 256, 16, log=LOG)
+print(B1.get_blob('foo'))
+print(B1.get_blob('baz'))
+LOG.warn('next foo')
+B1.set_blob('baz', b'asdfalskdfjalksdfasdfkasdfkjh')
+B1.set_blob('foo', b'asdfalskdfjalksdfasdfkasdfkjh2')
+open('eeprom.dat', 'wb').write(B1.buffer)
+
+print(B1.get_blob('foo'))