diff options
-rw-r--r-- | airspy/__init__.py | 6 | ||||
-rw-r--r-- | airspy/libairspy.py | 9 | ||||
-rw-r--r-- | test.py | 28 |
3 files changed, 39 insertions, 4 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); @@ -1,9 +1,35 @@ #!/usr/bin/python3 import os -from airspy import * from ctypes import * import time import sys import wave import struct +try: + from airspy import * +except ImportError: + print("Probably unsuported version of libairspy") + sys.exit(1) +print("Check airspy version") +device = airspy_device_t_p(None) + +p = airspy_lib_version_t() +libairspy.airspy_lib_version(byref(p)) +print(p.major_version) +print(p.minor_version) +print(p.revision) + +result = libairspy.airspy_init() +if (result != airspy_error.AIRSPY_SUCCESS): + print("Airspy init failed %s (%d)"%(libairspy.airspy_error_name(result), result)) + sys.exit(1) + +result = libairspy.airspy_open(byref(device)) + +board_id = c_uint8(airspy_board_id.AIRSPY_BOARD_ID_INVALID) +#result = libairspy.airspy_board_id_read(device, byref(board_id)) +print("Board ID Number: %s "%(str(board_id))) + + +libairspy.airspy_exit() |