From: Robin Krens Date: Sat, 10 Feb 2024 14:16:14 +0000 (+0100) Subject: tests: add status err test X-Git-Tag: v0.0.1~50 X-Git-Url: https://robinkrens.nl/gitweb/?a=commitdiff_plain;h=2d74aaa29ad36ab47de232aca47c559dd6bf81d4;p=renesas-ra-flasher tests: add status err test --- diff --git a/flasher/flasher.py b/flasher/flasher.py index 055bce3..8ef9728 100644 --- a/flasher/flasher.py +++ b/flasher/flasher.py @@ -34,18 +34,20 @@ STATUS_OK = 0x00 STATUS_ERR = 0x80 # Error codes -ERR_UNSU = 0xC -ERR_PCKT = 0xC1 -ERR_CHKS = 0xC2 -ERR_FLOW = 0xC3 -ERR_ADDR = 0xD0 -ERR_BAUD = 0xD4 -ERR_PROT = 0xDA -ERR_ID = 0xDB -ERR_SERI = 0xDC -ERR_ERA = 0xE1 -ERR_WRI = 0xE2 -ERR_SEQ = 0xE7 +error_codes = { + 0xC: "ERR_UNSU", + 0xC1: "ERR_PCKT", + 0xC2: "ERR_CHKS", + 0xC3: "ERR_FLOW", + 0xD0: "ERR_ADDR", + 0xD4: "ERR_BAUD", + 0xDA: "ERR_PROT", + 0xDB: "ERR_ID", + 0xDC: "ERR_SERI", + 0xE1: "ERR_ERA", + 0xE2: "ERR_WRI", + 0xE7: "ERR_SEQ" +} # used for init sequence LOW_PULSE = 0x00 @@ -74,7 +76,7 @@ def calc_sum(cmd, data): # format of data packet is [SOD|LNH|LNL|COM|byte_data|SUM|ETX] -def format_command(cmd, data): +def pack_command(cmd, data): SOD = 0x01 COM = cmd @@ -93,7 +95,7 @@ def format_command(cmd, data): return fmt # format of data packet is [SOD|LNH|LNL|RES|DAT|SUM|ETX] -def format_data(res, data): +def pack_pkt(res, data): SOD = 0x81 if (len(data) >= 1024): raise Exception(f'Data packet too large, data length is {DATA_LEN} (>1024)') @@ -105,21 +107,21 @@ def format_data(res, data): fmt_footer = 'BB' fmt = fmt_header + str(len(data)) + 's' + fmt_footer pack = struct.pack(fmt, SOD, LNH, LNL, RES, DAT, SUM, ETX) - print(fmt, pack, len(pack)) + return pack # packet received from mcu -def unpack_header(data): +def unpack_pkt(data): header = data[0:4] fmt_header = '