GetUnitInfo for PS2000a on Python

Post general discussions on using our drivers to write your own software here
Post Reply
ksalem
Newbie
Posts: 0
Joined: Mon Mar 11, 2019 10:23 am

GetUnitInfo for PS2000a on Python

Post by ksalem »

Good morning,
I am trying to get any type of information from my PicoScope.
Here is the code:

class iScopeWrapper():
def __init__(self):
self.handle = c_int16()
ps.ps2000aOpenUnit(byref(self.handle), None)

def get_unit_info(self):
info_string = create_string_buffer(256)
info_len = c_short(256)
req_len = c_short() #I tried this with 0, 8 and 256 and had the same result
return ps.ps2000aGetUnitInfo(self.handle, info_string, info_len, byref(req_len), 0)

if __name__ == "__main__":
scope = iScopeWrapper()
print(scope.get_unit_info())

The last digit (0) stands for the driver version according to the dictionary PICO_INFO. But it doesn't matter which information I am trying to extract from the PicoScope the output is always 0 or for the MAC address some number where I couldn't make sense of.

Am I doing something wrong here?
Thanks in advance

AndersErikssonConsat
Newbie
Posts: 0
Joined: Fri Nov 11, 2022 1:10 pm

Re: GetUnitInfo for PS2000a on Python

Post by AndersErikssonConsat »

Hi!
I finaly got it to work!
added the following after the ps2000aOpenUnit

# Open 2000 series PicoScope
# Returns handle to chandle for use in future API functions
status["openunit"] = ps.ps2000aOpenUnit(ctypes.byref(chandle), None)
assert_pico_ok(status["openunit"])

# read unit info
str_length = 100
string = ctypes.create_string_buffer(str_length)
requiredSize = ctypes.c_int16()

for info_type in ps.PICO_INFO:
status[info_type] = ps.ps2000aGetUnitInfo(chandle,
string,
str_length,
ctypes.byref(requiredSize),
ps.PICO_INFO[info_type])

print(f'{info_type}={string.value.decode()}')


And it outputs the following versions:

PICO_DRIVER_VERSION=2.1.82.3072
PICO_USB_VERSION=2.0
PICO_HARDWARE_VERSION=1
PICO_VARIANT_INFO=2205MSO
PICO_BATCH_AND_SERIAL=AR602/105
PICO_CAL_DATE=07Feb12
PICO_KERNEL_VERSION=1.0
PICO_DIGITAL_HARDWARE_VERSION=1
PICO_ANALOGUE_HARDWARE_VERSION=1
PICO_FIRMWARE_VERSION_1=1.3.3.0
PICO_FIRMWARE_VERSION_2=0.2.48.0
PICO_MAC_ADDRESS=
PICO_SHADOW_CAL=
PICO_IPP_VERSION=1.4.0-133

Kind regards,
Anders

Post Reply