From b1bb81e8b8e187c914a68685a55a5b9dcba682c2 Mon Sep 17 00:00:00 2001 From: Arturs Artamonovs Date: Thu, 20 Jul 2023 18:14:15 +0100 Subject: Added check for library version. Writing test script --- airspy/libairspy.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'airspy/libairspy.py') diff --git a/airspy/libairspy.py b/airspy/libairspy.py index c5c391f..a642b98 100644 --- a/airspy/libairspy.py +++ b/airspy/libairspy.py @@ -169,6 +169,13 @@ airspy_sample_block_cb_fn = PYFUNCTYPE(c_int, POINTER(airspy_transfer_t)) f = libairspy.airspy_lib_version f.restype, f.argtypes = None, [POINTER(airspy_lib_version_t)] +#try to load the lib version if its wrong print out warning +version = airspy_lib_version_t() +libairspy.airspy_lib_version(byref(version)) +if False == ((int(version.major_version) == 1) and (int(version.minor_version) == 0) and (int(version.revision) == 11)): + print("Unsuported version of libairspy.") + print("Only supporting 1.0.11") + raise ImportError #/* airspy_init() deprecated */ #extern ADDAPI int ADDCALL airspy_init(void); @@ -288,7 +295,7 @@ f.restype, f.argtypes = c_int, [airspy_device_t_p, POINTER(c_uint8)] #/* Parameter length shall be at least 128bytes to avoid possible string clipping */ #extern ADDAPI int ADDCALL airspy_version_string_read(struct airspy_device* device, char* version, uint8_t length); -f = libairspy.airspy_board_id_read +f = libairspy.airspy_version_string_read f.restype, f.argtypes = c_int, [airspy_device_t_p, c_char_p, c_uint8] #extern ADDAPI int ADDCALL airspy_board_partid_serialno_read(struct airspy_device* device, airspy_read_partid_serialno_t* read_partid_serialno); -- cgit v1.2.3