def init_device(cls, ctrl_connection: Connection, is_tx: bool, parameters: OrderedDict) -> bool: identifier = parameters["identifier"] try: device_list = sdrplay.get_devices() device_number = int(identifier) ctrl_connection.send("CONNECTED DEVICES: {}".format(", ".join( map(cls.device_dict_to_string, device_list)))) ret = sdrplay.set_device_index(device_number) ctrl_connection.send("SET DEVICE NUMBER to {}:{}".format( device_number, ret)) except (TypeError, ValueError) as e: logger.exception(e) return False device_model = device_list[device_number]["hw_version"] sdrplay.set_gr_mode_for_dev_model(device_model) if device_model == 2: antenna = parameters[cls.Command.SET_ANTENNA_INDEX.name] cls.process_command((cls.Command.SET_ANTENNA_INDEX.name, antenna), ctrl_connection, is_tx=False) else: ctrl_connection.send("Skipping antenna selection for RSP1 device") cls.sdrplay_initial_freq = parameters[cls.Command.SET_FREQUENCY.name] cls.sdrplay_initial_sample_rate = parameters[ cls.Command.SET_SAMPLE_RATE.name] cls.sdrplay_initial_bandwidth = parameters[ cls.Command.SET_BANDWIDTH.name] cls.sdrplay_initial_gain = parameters[cls.Command.SET_RF_GAIN.name] cls.sdrplay_initial_if_gain = parameters[cls.Command.SET_IF_GAIN.name] cls.sdrplay_device_index = identifier return True
def test_c_wrapper(self): def pycallback(data): arr = np.asarray(data) #result = np.empty(len(arr) // 2, dtype=np.complex64) #result.real = (arr[::2] + 0.5) / 32767.5 #result.imag = (arr[1::2] + 0.5) / 32767.5 print(sdrplay.get_api_version()) print(sdrplay.get_devices()) print(sdrplay.set_device_index(0)) parent_conn, child_conn = Pipe() p = Process(target=recv, args=(parent_conn, )) p.daemon = True p.start() null_ptr = ctypes.POINTER(ctypes.c_voidp)() print("Init stream", sdrplay.init_stream(50, 2e6, 433.92e6, 2e6, 500, child_conn)) time.sleep(2) print("settings sample rate") print("Set sample rate", sdrplay.set_sample_rate(2e6)) time.sleep(1) p.terminate() p.join()
def test_c_wrapper(self): def pycallback(data): arr = np.asarray(data) #result = np.empty(len(arr) // 2, dtype=np.complex64) #result.real = (arr[::2] + 0.5) / 32767.5 #result.imag = (arr[1::2] + 0.5) / 32767.5 print(sdrplay.get_api_version()) print(sdrplay.get_devices()) print(sdrplay.set_device_index(0)) parent_conn, child_conn = Pipe() p = Process(target=recv, args=(parent_conn,)) p.daemon = True p.start() null_ptr = ctypes.POINTER(ctypes.c_voidp)() print("Init stream", sdrplay.init_stream(50, 2e6, 433.92e6, 2e6, 500, child_conn)) time.sleep(2) print("settings sample rate") print("Set sample rate", sdrplay.set_sample_rate(2e6)) time.sleep(1) p.terminate() p.join()
def get_device_list(cls): return [cls.device_dict_to_string(d) for d in sdrplay.get_devices()]