Updated regex for Py37
This commit is contained in:
parent
ad87c93afc
commit
f73640aee4
2 changed files with 10 additions and 10 deletions
|
|
@ -199,15 +199,15 @@ class ExtensibleSerialInstrument(object):
|
||||||
response_regex = response_string
|
response_regex = response_string
|
||||||
noop = lambda x: x #placeholder null parse function
|
noop = lambda x: x #placeholder null parse function
|
||||||
placeholders = [ #tuples of (regex matching placeholder, regex to replace it with, parse function)
|
placeholders = [ #tuples of (regex matching placeholder, regex to replace it with, parse function)
|
||||||
(r"%c",r".", noop),
|
(r"%c", r".", noop),
|
||||||
(r"%(\d+)c",r".{\1}", noop), #TODO support %cn where n is a number of chars
|
(r"%(\d+)c", r".{\1}", noop), #TODO support %cn where n is a number of chars
|
||||||
(r"%d",r"[-+]?\d+", int),
|
(r"%d", r"[-+]?\\d+", int),
|
||||||
(r"%[eEfg]",r"[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?", float),
|
(r"%[eEfg]", r"[-+]?(?:\\d+(?:\.\\d*)?|\.\\d+)(?:[eE][-+]?\\d+)?", float),
|
||||||
(r"%i",r"[-+]?(?:0[xX][\dA-Fa-f]+|0[0-7]*|\d+)", lambda x: int(x, 0)), #0=autodetect base
|
(r"%i", r"[-+]?(?:0[xX][\\dA-Fa-f]+|0[0-7]*|\\d+)", lambda x: int(x, 0)), #0=autodetect base
|
||||||
(r"%o",r"[-+]?[0-7]+", lambda x: int(x, 8)), #8 means octal
|
(r"%o", r"[-+]?[0-7]+", lambda x: int(x, 8)), #8 means octal
|
||||||
(r"%s",r"\S+",noop),
|
(r"%s", r"\\s+", noop),
|
||||||
(r"%u",r"\d+",int),
|
(r"%u", r"\\d+", int),
|
||||||
(r"%[xX]",r"[-+]?(?:0[xX])?[\dA-Fa-f]+",lambda x: int(x, 16)), #16 forces hexadecimal
|
(r"%[xX]", r"[-+]?(?:0[xX])?[\\dA-Fa-f]+", lambda x: int(x, 16)), #16 forces hexadecimal
|
||||||
]
|
]
|
||||||
matched_placeholders = []
|
matched_placeholders = []
|
||||||
for placeholder, regex, parse_fun in placeholders:
|
for placeholder, regex, parse_fun in placeholders:
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ class Sangaboard(ExtensibleSerialInstrument):
|
||||||
|
|
||||||
# Request firmware version from the board
|
# Request firmware version from the board
|
||||||
self.firmware = self.query("version",timeout=2).rstrip()
|
self.firmware = self.query("version",timeout=2).rstrip()
|
||||||
|
logging.info("Firmware response: {}".format(self.firmware))
|
||||||
# Check for valid firmware string
|
# Check for valid firmware string
|
||||||
if self.firmware:
|
if self.firmware:
|
||||||
match = re.match(r"Sangaboard Firmware v(([\d]+)(?:\.([\d]+))+)", self.firmware)
|
match = re.match(r"Sangaboard Firmware v(([\d]+)(?:\.([\d]+))+)", self.firmware)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue