From 4bc6115f1a1dcfe5cebd23adb43326a91f68c094 Mon Sep 17 00:00:00 2001 From: James O'Shannessy <12959316+joshanne@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:47:21 +1100 Subject: [PATCH] hwdef: Update scripts to parse CSV files properly fails because of iterator not returning strings and 'dict' object has no attribute 'iterkeys'. Fixed so both scripts run. --- libraries/AP_HAL_ChibiOS/hwdef/scripts/addfunc_parse.py | 2 +- libraries/AP_HAL_ChibiOS/hwdef/scripts/af_parse.py | 4 ++-- libraries/AP_HAL_ChibiOS/hwdef/scripts/dma_parse.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/addfunc_parse.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/addfunc_parse.py index 4f5ebc5a46..609814fe0e 100755 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/addfunc_parse.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/addfunc_parse.py @@ -28,7 +28,7 @@ def is_pin(str): return False def parse_adc_table(fname, table): - csvt = csv.reader(open(fname,'rb')) + csvt = csv.reader(open(fname,'r')) i = 0 for row in csvt: for col in row: diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/af_parse.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/af_parse.py index b5940b9861..dd3b1774ea 100755 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/af_parse.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/af_parse.py @@ -86,10 +86,10 @@ if len(sys.argv) != 2: parse_af_table(sys.argv[1], table) -sys.stdout.write("AltFunction_map = {\n"); +sys.stdout.write("AltFunction_map = {\n") sys.stdout.write('\t# format is PIN:FUNCTION : AFNUM\n') sys.stdout.write('\t# extracted from %s\n' % os.path.basename(sys.argv[1])) for k in sorted(table.keys(), key=cmp_to_key(pin_compare)): s = '"' + k + '"' sys.stdout.write('\t%-20s\t:\t%s,\n' % (s, table[k])) -sys.stdout.write("}\n"); +sys.stdout.write("}\n") diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/dma_parse.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/dma_parse.py index d0edd0f57f..f4dbab8fd5 100755 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/dma_parse.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/dma_parse.py @@ -11,7 +11,7 @@ import sys, csv, os def parse_dma_table(fname, table): dma_num = 1 - csvt = csv.reader(open(fname,'rb')) + csvt = csv.reader(open(fname,'r')) i = 0 last_channel = -1 for row in csvt: @@ -78,7 +78,7 @@ sys.stdout.write("DMA_Map = {\n"); sys.stdout.write('\t# format is (DMA_TABLE, StreamNum, Channel)\n') sys.stdout.write('\t# extracted from %s\n' % os.path.basename(sys.argv[1])) -for k in sorted(table.iterkeys()): +for k in sorted(table.keys()): s = '"%s"' % k sys.stdout.write('\t%-10s\t:\t[' % s) for i in range(len(table[k])):