Skip to content

Commit

Permalink
Merge pull request #176 from bmoneke/FixOpenWithSerial
Browse files Browse the repository at this point in the history
Fix opening by serial number #169
  • Loading branch information
hmaarrfk authored Oct 15, 2021
2 parents 2a8bdd7 + 8db583d commit 533ec3b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 43 deletions.
11 changes: 6 additions & 5 deletions picoscope/ps3000a.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,15 @@ def __init__(self, serialNumber=None, connect=True):

super(PS3000a, self).__init__(serialNumber, connect)

def _lowLevelOpenUnit(self, sn):
def _lowLevelOpenUnit(self, serialNumber):
c_handle = c_int16()
if sn is not None:
serialNullTermStr = byref(create_string_buffer(sn))
if serialNumber is not None:
serialNumberStr = create_string_buffer(bytes(serialNumber,
encoding='utf-8'))
else:
serialNullTermStr = None
serialNumberStr = None
# Passing None is the same as passing NULL
m = self.lib.ps3000aOpenUnit(byref(c_handle), serialNullTermStr)
m = self.lib.ps3000aOpenUnit(byref(c_handle), serialNumberStr)
self.handle = c_handle.value

# copied over from ps5000a:
Expand Down
23 changes: 12 additions & 11 deletions picoscope/ps4000.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,26 +158,27 @@ def __init__(self, serialNumber=None, connect=True):
raise NotImplementedError('Timebase functions have not been '
'written for the ' + unit_number)

def _lowLevelOpenUnit(self, sn):
def _lowLevelOpenUnit(self, serialNumber):
c_handle = c_int16()
if sn is not None:
serialNullTermStr = create_string_buffer(sn)
if serialNumber is not None:
serialNumberStr = create_string_buffer(bytes(serialNumber,
encoding='utf-8'))
else:
serialNullTermStr = None
serialNumberStr = None
# Passing None is the same as passing NULL
m = self.lib.ps4000OpenUnit(byref(c_handle), serialNullTermStr)
m = self.lib.ps4000OpenUnit(byref(c_handle), serialNumberStr)
self.checkResult(m)
self.handle = c_handle.value

def _lowLevelOpenUnitAsync(self, sn):
def _lowLevelOpenUnitAsync(self, serialNumber):
c_status = c_int16()
if sn is not None:
serialNullTermStr = create_string_buffer(sn)
if serialNumber is not None:
serialNumberStr = create_string_buffer(bytes(serialNumber,
encoding='utf-8'))
else:
serialNullTermStr = None

serialNumberStr = None
# Passing None is the same as passing NULL
m = self.lib.ps4000OpenUnitAsync(byref(c_status), serialNullTermStr)
m = self.lib.ps4000OpenUnitAsync(byref(c_status), serialNumberStr)
self.checkResult(m)

return c_status.value
Expand Down
23 changes: 12 additions & 11 deletions picoscope/ps5000.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,26 +153,27 @@ def __init__(self, serialNumber=None, connect=True):

super(PS5000, self).__init__(serialNumber, connect)

def _lowLevelOpenUnit(self, sn):
def _lowLevelOpenUnit(self, serialNumber):
c_handle = c_int16()
if sn is not None:
serialNullTermStr = create_string_buffer(sn)
if serialNumber is not None:
serialNumberStr = create_string_buffer(bytes(serialNumber,
encoding='utf-8'))
else:
serialNullTermStr = None
serialNumberStr = None
# Passing None is the same as passing NULL
m = self.lib.ps5000OpenUnit(byref(c_handle), serialNullTermStr)
m = self.lib.ps5000OpenUnit(byref(c_handle), serialNumberStr)
self.checkResult(m)
self.handle = c_handle.value

def _lowLevelOpenUnitAsync(self, sn):
def _lowLevelOpenUnitAsync(self, serialNumber):
c_status = c_int16()
if sn is not None:
serialNullTermStr = create_string_buffer(sn)
if serialNumber is not None:
serialNumberStr = create_string_buffer(bytes(serialNumber,
encoding='utf-8'))
else:
serialNullTermStr = None

serialNumberStr = None
# Passing None is the same as passing NULL
m = self.lib.ps5000OpenUnitAsync(byref(c_status), serialNullTermStr)
m = self.lib.ps5000OpenUnitAsync(byref(c_status), serialNumberStr)
self.checkResult(m)

return c_status.value
Expand Down
11 changes: 6 additions & 5 deletions picoscope/ps5000a.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,15 @@ def __init__(self, serialNumber=None, connect=True):

super(PS5000a, self).__init__(serialNumber, connect)

def _lowLevelOpenUnit(self, sn):
def _lowLevelOpenUnit(self, serialNumber):
c_handle = c_int16()
if sn is not None:
serialNullTermStr = create_string_buffer(sn)
if serialNumber is not None:
serialNumberStr = create_string_buffer(bytes(serialNumber,
encoding='utf-8'))
else:
serialNullTermStr = None
serialNumberStr = None
# Passing None is the same as passing NULL
m = self.lib.ps5000aOpenUnit(byref(c_handle), serialNullTermStr,
m = self.lib.ps5000aOpenUnit(byref(c_handle), serialNumberStr,
self.resolution)
self.handle = c_handle.value

Expand Down
23 changes: 12 additions & 11 deletions picoscope/ps6000.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,26 +154,27 @@ def __init__(self, serialNumber=None, connect=True):

super(PS6000, self).__init__(serialNumber, connect)

def _lowLevelOpenUnit(self, sn):
def _lowLevelOpenUnit(self, serialNumber):
c_handle = c_int16()
if sn is not None:
serialNullTermStr = create_string_buffer(sn)
if serialNumber is not None:
serialNumberStr = create_string_buffer(bytes(serialNumber,
encoding='utf-8'))
else:
serialNullTermStr = None
serialNumberStr = None
# Passing None is the same as passing NULL
m = self.lib.ps6000OpenUnit(byref(c_handle), serialNullTermStr)
m = self.lib.ps6000OpenUnit(byref(c_handle), serialNumberStr)
self.checkResult(m)
self.handle = c_handle.value

def _lowLevelOpenUnitAsync(self, sn):
def _lowLevelOpenUnitAsync(self, serialNumber):
c_status = c_int16()
if sn is not None:
serialNullTermStr = create_string_buffer(sn)
if serialNumber is not None:
serialNumberStr = create_string_buffer(bytes(serialNumber,
encoding='utf-8'))
else:
serialNullTermStr = None

serialNumberStr = None
# Passing None is the same as passing NULL
m = self.lib.ps6000OpenUnitAsync(byref(c_status), serialNullTermStr)
m = self.lib.ps6000OpenUnitAsync(byref(c_status), serialNumberStr)
self.checkResult(m)

return c_status.value
Expand Down

0 comments on commit 533ec3b

Please sign in to comment.