mirror of
https://github.com/GiggioG/thermal-printer.git
synced 2026-06-14 18:20:18 +00:00
begin documenting the project, README
This commit is contained in:
18
reverse_engineering/dataToBin.py
Normal file
18
reverse_engineering/dataToBin.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import os
|
||||
import glob
|
||||
|
||||
os.makedirs("databin", exist_ok=True)
|
||||
|
||||
for data_file in glob.glob("data/data*.txt"):
|
||||
with open(data_file, "r") as f:
|
||||
hex_data = f.read().replace('\n', '').replace(' ', '')
|
||||
|
||||
# Convert hex string to bytes
|
||||
byte_data = bytes.fromhex(hex_data)
|
||||
|
||||
# Generate output filename: databin/data#.bin
|
||||
base = os.path.splitext(os.path.basename(data_file))[0]
|
||||
out_file = f"databin/{base}.bin"
|
||||
|
||||
with open(out_file, "wb") as fout:
|
||||
fout.write(byte_data)
|
||||
Reference in New Issue
Block a user