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.
This commit is contained in:
Damien George
2014-04-16 11:45:52 +01:00
parent bda2f70964
commit ecdf6cdc5b
2 changed files with 4 additions and 2 deletions

View File

@@ -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 match.group(1) == 'USBD_VID':
rv['USB_VID'] = match.group(2)