From 5b75aff608197bd4b229e89274988ebdfb522a80 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 4 Jul 2013 22:28:25 +0000 Subject: fixed issues with short answers bootloader now has working stubs for all commands git-svn-id: https://svn.spreadspace.org/pic/trunk@36 a09c6847-51d9-44de-8ef2-e725cf50f3c7 --- downloader/downloader.py | 43 +++++++++++++++++++++---------------------- downloader/proto.txt | 9 ++++----- 2 files changed, 25 insertions(+), 27 deletions(-) (limited to 'downloader') diff --git a/downloader/downloader.py b/downloader/downloader.py index 00b50a4..3a66f3b 100755 --- a/downloader/downloader.py +++ b/downloader/downloader.py @@ -89,7 +89,7 @@ def open_serial(device, baud): 9600: termios.B9600, 19200: termios.B19200, 38400: termios.B38400, 57600: termios.B57600, 115200: termios.B115200, 230400: termios.B230400 } - baudreate = termios.B19200 + baudreate = termios.B57600 try: baudrate = baudrates[int(baud)] except (KeyError, ValueError): @@ -123,17 +123,15 @@ def exec_command(dev, cmd, answer): return_codes = { 0: "OK", 1: "invalid command", 2: "bad checksum", 3: "not implemented", 4: "flash write error", - 5: "address invalid", 6: "address prohibited" } - - answer = '<' + answer + 'B' - answer_len = struct.calcsize(answer) + 2 + 5: "address invalid", 6: "address prohibited", + 7: "value out of bounds" } cstr = cmd + chr(calc_csum(cmd)) os.write(dev, cstr) astr = b'' - while len(astr) < 2: - astr += os.read(dev, 2 - len(astr)) + while len(astr) < 3: + astr += os.read(dev, 3 - len(astr)) if astr[0] != cmd[0]: print "ERROR: bootloader returned wrong command code" @@ -149,6 +147,7 @@ def exec_command(dev, cmd, answer): print "ERROR: bootloader returned %d: %s" % (ret, rstr) sys.exit(4) + answer_len = struct.calcsize(answer) + len(astr) while len(astr) < answer_len: astr += os.read(dev, answer_len - len(astr)) @@ -161,7 +160,7 @@ def exec_command(dev, cmd, answer): ### Commands def identify(dev): - data = exec_command(dev, 'i', 'BB10sHBHH') + data = exec_command(dev, 'i', ' value it is ok to write less than bytes. Also - this only applies to eeprom writes, reading the eeprom is much faster and - therefore not subject to this limitation. + This represents the maximum number of eeprom bytes which may be written or + read at once. Unlike value it is ok to write or read less than + bytes. supported: 2bytes, a bitmap showing supported commands -- cgit v1.2.3