Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EnumerateUnits throws an error if NULL pointer arguments are provided. #183

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions picoscope/ps3000a.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,16 @@ def _lowLevelCloseUnit(self):

def _lowLevelEnumerateUnits(self):
count = c_int16(0)
m = self.lib.ps3000aEnumerateUnits(byref(count), None, None)
self.checkResult(m)
# a serial number is rouhgly 8 characters
# an extra character for the comma
# and an extra one for the space after the comma?
# the extra two also work for the null termination
serialLth = c_int16(count.value * (8 + 2))
# The EnumeratUnits functions returns an error if NULL pointers
# are given as parameters. Thus it is not possible to determine the
# number of devices beforehand - if we assume that there will
# never be more than 16 devices connected, we should get along with
# a buffer that fits 16 serial numbers.
serialLth = c_int16(16 * (8 + 2))
serials = create_string_buffer(serialLth.value + 1)

m = self.lib.ps3000aEnumerateUnits(byref(count), serials,
Expand Down