diff options
author | Arturs Artamonovs <dos21h@gmail.com> | 2023-07-20 18:14:15 +0100 |
---|---|---|
committer | Arturs Artamonovs <dos21h@gmail.com> | 2023-07-20 18:14:15 +0100 |
commit | b1bb81e8b8e187c914a68685a55a5b9dcba682c2 (patch) | |
tree | 1e9b6dffb8a8454e7edc8e64c8191257fb931c07 /airspy | |
parent | 9c6cb97a447925411a6e346b98ba59b007615997 (diff) | |
download | pyairspy-b1bb81e8b8e187c914a68685a55a5b9dcba682c2.tar.gz pyairspy-b1bb81e8b8e187c914a68685a55a5b9dcba682c2.zip |
Added check for library version. Writing test script
Diffstat (limited to 'airspy')
-rw-r--r-- | airspy/__init__.py | 6 | ||||
-rw-r--r-- | airspy/libairspy.py | 9 |
2 files changed, 12 insertions, 3 deletions
diff --git a/airspy/__init__.py b/airspy/__init__.py index 95f6fac..1e451d4 100644 --- a/airspy/__init__.py +++ b/airspy/__init__.py @@ -1,5 +1,7 @@ -from .libairspy import libairspy +from .libairspy import libairspy, airspy_lib_version_t, airspy_error,airspy_device_t_p, airspy_board_id from .airspy import AirSpy +from ctypes import * + +__all__ = ["libairspy", "AirSpy", "airspy_lib_version_t", "airspy_error","airspy_device_t_p", "airspy_board_id" ] -__all__ = ["libairspy", "AirSpy" ]
\ No newline at end of file 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); |