Commit ecdf6cdc authored by Damien George's avatar Damien George
Browse files

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.
parent bda2f709
......@@ -10,7 +10,9 @@ from __future__ import print_function
import sys
# Can either be set explicitly, or left blank to auto-detect
line_end = ''
# Except auto-detect doesn't work because the file has been passed
# through Python text processing, which makes all EOL a \n
line_end = '\\r\\n'
if __name__ == "__main__":
filename = sys.argv[1]
......@@ -13,7 +13,7 @@ def parse_usb_ids(filename):
if filename == 'usbd_desc_cdc_msc.c':
for line in open(filename).readlines():
line = line.rstrip('\r\n')
match = re.match('^#define\s+(\w+)\s+0x(\d+)$', line)
match = re.match('^#define\s+(\w+)\s+0x([0-9A-Fa-f]+)$', line)
if match:
if == 'USBD_VID':
rv['USB_VID'] =
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment