Working on analysis
This commit is contained in:
parent
a6f75b2ce5
commit
3e782060fb
5 changed files with 3700 additions and 10 deletions
3649
gm_platform/fw/grid_scope.ipynb
Normal file
3649
gm_platform/fw/grid_scope.ipynb
Normal file
File diff suppressed because one or more lines are too long
30
gm_platform/fw/reader.py
Normal file
30
gm_platform/fw/reader.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import struct
|
||||
|
||||
import sqlite3
|
||||
|
||||
import serial
|
||||
from cobs import cobs
|
||||
|
||||
if __name__ == '__main__':
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-b', '--baudrate', type=int, default=250000)
|
||||
parser.add_argument('port')
|
||||
parser.add_argument('dbfile')
|
||||
args = parser.parse_args()
|
||||
|
||||
db = sqlite3.connect(args.db)
|
||||
ser = serial.Serial(args.port, args.baudrate)
|
||||
|
||||
while True:
|
||||
packet = ser.read_until(b'\0')
|
||||
try:
|
||||
packet = cobs.decode(packet)
|
||||
crc, seq, struct.decode('IBxH', packet[:8])
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
|
@ -29,7 +29,6 @@ ctrl_reset = lambda: ctrl_packet(CtrlPacketTypes.RESET)
|
|||
ctrl_ack = lambda pid: ctrl_packet(CtrlPacketTypes.ACK, pid)
|
||||
ctrl_retransmit = lambda pid: ctrl_packet(CtrlPacketTypes.RETRANSMIT, pid)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser()
|
||||
|
|
@ -71,6 +70,7 @@ if __name__ == '__main__':
|
|||
last_pid = None
|
||||
lines_written = 0
|
||||
cur = db.cursor()
|
||||
capture_start = time()
|
||||
while True:
|
||||
#ser.write(cobs.encode(b'\x01\xff') + b'\0')
|
||||
data = ser.read_until(b'\0')
|
||||
|
|
@ -91,17 +91,25 @@ if __name__ == '__main__':
|
|||
# Calculate byte-wise CRC32
|
||||
our_crc = zlib.crc32(bytes(b for x in payload for b in (0, 0, 0, x)))
|
||||
#log.append((time(), seq, crc32, our_crc, pid, data))
|
||||
print(f'{ts:>7.3f} {seq:05d} {crc32:08x} {our_crc:08x} {pid} {hexlify(data).decode()}', end='')
|
||||
bars = '\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588'
|
||||
sparkline = ''.join(bars[int(x/4096*8)] for x in struct.unpack('<32H', data))
|
||||
print(f'\033[38;5;249m{ts-capture_start:>10.3f}',
|
||||
f'\033[94m{seq:05d}',
|
||||
f'\033[38;5;243m{crc32:08x}',
|
||||
f'\033[38;5;243m{our_crc:08x}',
|
||||
f'\033[38;5;243m{pid}',
|
||||
f'\033[0m{hexlify(data).decode()}',
|
||||
f'\033[94m{sparkline}\033[0m', end='')
|
||||
|
||||
error = False
|
||||
suppress_ack = False
|
||||
if crc32 != our_crc:
|
||||
print(' CRC ERROR', end='')
|
||||
print(' \033[1;91mCRC ERROR\033[0m', end='')
|
||||
suppress_ack = True
|
||||
error = True
|
||||
|
||||
if last_pid is not None and pid != (last_pid+1)%8:
|
||||
print(' PID ERROR', end='')
|
||||
print(' \033[1;93mPID ERROR\033[0m', end='')
|
||||
error = True
|
||||
else:
|
||||
last_pid = pid
|
||||
|
|
@ -121,6 +129,8 @@ if __name__ == '__main__':
|
|||
if lines_written == 80:
|
||||
lines_written = 0
|
||||
print('\033[2J\033[H', end='')
|
||||
delta = ts-capture_start
|
||||
print(f'\033[7mRun {run_id}, capturing for {delta//3600//24:> 3.0f}:{delta//3600%24:02.0f}:{delta//60%60:02.0f}:{delta%60:06.3f}\033[0m')
|
||||
db.commit()
|
||||
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -3021,5 +3021,5 @@ F 5 "SDCIT/8GB" H 12700 7050 50 0001 C CNN "Reichelt"
|
|||
1 0 0 -1
|
||||
$EndComp
|
||||
Text Notes 850 11050 0 50 ~ 0
|
||||
TO-DO\n* Add adc buffer op amp\n* join input resistors, adjust divider\n* earth secondary side\n* add slots for large isolation barrier\n* add slots for small isolation barrier\n* fixup/remove ocxo footprint\n* fixup converter footprint, use smaller part? use 5V one and power raspi?\n* remove uart isolation?\n* fix fuse rating\n* remove one fuse\n* remove lid switches?\n* fixup incorrect bom items\n* CH340 V3 cap -> 100n\n* replace CH340 w/ silabs cp2102\n* replace optocoupler pullups w/ 350R
|
||||
TO-DO\n* Add adc buffer op amp\n* join input resistors, adjust divider\n* earth secondary side\n* add slots for large isolation barrier\n* add slots for small isolation barrier\n* fixup/remove ocxo footprint\n* fixup converter footprint, use smaller part? use 5V one and power raspi?\n* remove uart isolation?\n* fix fuse rating\n* remove one fuse\n* remove lid switches?\n* fixup incorrect bom items\n* CH340 V3 cap -> 100n\n* replace CH340 w/ silabs cp2102\n* replace optocoupler pullups w/ 350R\n* Remove 3V6 limiting zener in vmeas circuit
|
||||
$EndSCHEMATC
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue