summaryrefslogtreecommitdiffstats
path: root/dump.py
blob: 5790130edaab004d8c11c69911b97a521d84d74c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import serial
import sys

if len(sys.argv) < 2:
    sys.stderr.write("Usage: {} /dev/ttySERIAL\n".format(sys.argv[0]))
    sys.exit(1)

s = serial.Serial(sys.argv[1], 115200)

def dump_block(block):
    s.write(chr(block))
    d = ""
    while True:
        d += s.read(1024)
        print "[i] Receiving block {}, {} bytes received...".format(block, len(d))
        if len(d) == 65536:
            return d

for i in range(64):
    data = dump_block(i)
    f = open("dumps/dump-block-%02i.bin" % i, "w")
    f.write(data)
    f.close()