diff --git a/parse.py b/parse.py new file mode 100644 index 0000000..8510585 --- /dev/null +++ b/parse.py @@ -0,0 +1,142 @@ +# -*- coding: utf-8 -*- + +# Python script to parse Bambu Lab RFID tag data +# Created for https://github.com/Bambu-Research-Group/RFID-Tag-Guide +# Written by Vinyl Da.i'gyu-Kazotetsu (www.queengoob.org), 2024 + +import sys +import struct +from datetime import datetime + +COMPARISON_BLOCKS = [1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14] +IMPORTANT_BLOCKS = [0] + COMPARISON_BLOCKS + +BYTES_PER_BLOCK = 16 +BLOCKS_PER_TAG = 64 +TOTAL_BYTES = BLOCKS_PER_TAG * BYTES_PER_BLOCK + +# Byte conversions +def bytes_to_string(data): + return data.decode('ascii').replace('\x00', ' ').strip() + +def bytes_to_hex(data, chunkify = False): + output = data.hex().upper() + return " ".join((string[0+i:2+i] for i in range(0, len(string), 2))) if chunkify else output + +def bytes_to_int(data): + return int.from_bytes(data, 'little') + +def bytes_to_float(data): + return struct.unpack(' 0: + tag.compare(data[i-1]) + print() + +if __name__ == "__main__": + data = load_data(sys.argv[1:]) + print_data(data, False)