Lagde funksjon for mtr spooling

This commit is contained in:
Trygve 2022-05-21 16:27:15 +02:00
parent 66ce00d496
commit 7abb532b90
1 changed files with 19 additions and 0 deletions

19
mtr.py Normal file
View File

@ -0,0 +1,19 @@
import otime
import serial
from time import sleep
def dump_all(port):
mtr = serial.Serial(port, baudrate=9600, timeout=40)
# dump all command
mtr.write(b'/SA')
card_dumps = []
sleep(0.4)
while mtr.in_waiting > 0:
mtr.read_until(expected=b'\xFF\xFF\xFF\xFF')
size = mtr.read(size=1)
if size == b'\xe6':
meat = mtr.read(229)
full = b'\xFF\xFF\xFF\xFF' + size + meat
card_r = otime.CardDump.from_mtr_bytes(full)
card_dumps.append(card_r)
return card_dumps