From 3243ceeb055c30f431055be03c7a11c30e6d813f Mon Sep 17 00:00:00 2001 From: rgilmore Date: Fri, 25 Mar 2016 16:51:38 +0000 Subject: [PATCH] edited regex so that it can accept a string with sections to it as found on Keysight DSO-S 204A typo --- usbtmc/usbtmc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/usbtmc/usbtmc.py b/usbtmc/usbtmc.py index 0c642a6..e35dc38 100644 --- a/usbtmc/usbtmc.py +++ b/usbtmc/usbtmc.py @@ -79,8 +79,11 @@ def parse_visa_resource_string(resource_string): # USB::1234::5678::SERIAL::INSTR # USB0::0x1234::0x5678::INSTR # USB0::0x1234::0x5678::SERIAL::INSTR + # USB::1234::4536::SERIAL::0::INSTR + # USB0::0x1234::0x4536::SERIAL::0::INSTR + m = re.match('^(?P(?PUSB)\d*)(::(?P[^\s:]+))' - '(::(?P[^\s:]+(\[.+\])?))(::(?P[^\s:]+))?' + '(::(?P[^\s:]+(\[.+\])?))(::(?P[^\s:]+))?(::(?P[^\s:]+))?' '(::(?PINSTR))$', resource_string, re.I) if m is not None: @@ -90,6 +93,7 @@ def parse_visa_resource_string(resource_string): arg1=m.group('arg1'), arg2=m.group('arg2'), arg3=m.group('arg3'), + arg4=m.group('arg4'), suffix=m.group('suffix') )