Skip to content

Commit ecdf6cd

Browse files
committed
tools: Fix up pybcdc.inf generation: new lines and hex digits.
Using Python's file open in 'r' mode opens it for text reading, which converts all new lines to \n. Could use 'rb' binary mode, but then don't have access to the string Template replacement functions. Thus, force the output to have '\\r\\n' ending. Also fix regex to match hex digits.
1 parent bda2f70 commit ecdf6cd

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

tools/file2h.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
import sys
1111

1212
# Can either be set explicitly, or left blank to auto-detect
13-
line_end = ''
13+
# Except auto-detect doesn't work because the file has been passed
14+
# through Python text processing, which makes all EOL a \n
15+
line_end = '\\r\\n'
1416

1517
if __name__ == "__main__":
1618
filename = sys.argv[1]

tools/insert-usb-ids.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def parse_usb_ids(filename):
1313
if filename == 'usbd_desc_cdc_msc.c':
1414
for line in open(filename).readlines():
1515
line = line.rstrip('\r\n')
16-
match = re.match('^#define\s+(\w+)\s+0x(\d+)$', line)
16+
match = re.match('^#define\s+(\w+)\s+0x([0-9A-Fa-f]+)$', line)
1717
if match:
1818
if match.group(1) == 'USBD_VID':
1919
rv['USB_VID'] = match.group(2)

0 commit comments

Comments
 (0)