script/slaveinfo2xml.py
changeset 937 e2ee1bed5bd6
parent 915 57907232b901
equal deleted inserted replaced
936:30fddfce8db6 937:e2ee1bed5bd6
   110         reVendor = re.compile('Vendor ID:.*\((\d+)\)')
   110         reVendor = re.compile('Vendor ID:.*\((\d+)\)')
   111         reProduct = re.compile('Product code:.*\((\d+)\)')
   111         reProduct = re.compile('Product code:.*\((\d+)\)')
   112         reRevision = re.compile('Revision number:.*\((\d+)\)')
   112         reRevision = re.compile('Revision number:.*\((\d+)\)')
   113         rePdo = re.compile('([RT])xPdo\s+0x([0-9A-F]+)')
   113         rePdo = re.compile('([RT])xPdo\s+0x([0-9A-F]+)')
   114         rePdoEntry = \
   114         rePdoEntry = \
   115             re.compile('0x([0-9A-F]+):([0-9A-F]+) +"([^"]*)", (\d+) bit')
   115             re.compile('0x([0-9A-F]+):([0-9A-F]+),\s+(\d+) bit,\s+"([^"]*)"')
   116         pdo = None
   116         pdo = None
   117         f = open(fileName, 'r')
   117         f = open(fileName, 'r')
   118         while True:
   118         while True:
   119             line = f.readline()
   119             line = f.readline()
   120             if not line: break
   120             if not line: break
   137                 self.pdos.append(pdo)
   137                 self.pdos.append(pdo)
   138 
   138 
   139             match = rePdoEntry.search(line)
   139             match = rePdoEntry.search(line)
   140             if match:
   140             if match:
   141                 pdoEntry = PdoEntry(int(match.group(1), 16), \
   141                 pdoEntry = PdoEntry(int(match.group(1), 16), \
   142                     int(match.group(2), 16), match.group(3), \
   142                     int(match.group(2), 16), match.group(4), \
   143                     int(match.group(4)))
   143                     int(match.group(3)))
   144                 pdo.appendEntry(pdoEntry)
   144                 pdo.appendEntry(pdoEntry)
   145 
   145 
   146         f.close()
   146         f.close()
   147 
   147 
   148     def toXmlDocument(self):
   148     def toXmlDocument(self):