Skip to content

Commit

Permalink
hwdef: Update scripts to parse CSV files properly
Browse files Browse the repository at this point in the history
fails because of iterator not returning strings and 'dict' object has no attribute 'iterkeys'. Fixed so both scripts run.
  • Loading branch information
joshanne authored and peterbarker committed Dec 16, 2024
1 parent 61ca071 commit 4bc6115
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion libraries/AP_HAL_ChibiOS/hwdef/scripts/addfunc_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions libraries/AP_HAL_ChibiOS/hwdef/scripts/af_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ def parse_af_table(fname, table):

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")
4 changes: 2 additions & 2 deletions libraries/AP_HAL_ChibiOS/hwdef/scripts/dma_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

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:
Expand Down Expand Up @@ -78,7 +78,7 @@ def check_full_table(table):
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])):
Expand Down

0 comments on commit 4bc6115

Please sign in to comment.