def shutdown_device(cls, ctrl_connection, is_tx: bool): limesdr.stop_stream() limesdr.destroy_stream() limesdr.disable_all_channels() ret = limesdr.close() ctrl_connection.send("CLOSE:" + str(ret)) return True
def shutdown_device(cls, ctrl_connection, is_tx: bool): limesdr.stop_stream() limesdr.destroy_stream() limesdr.disable_all_channels() ret = limesdr.close() ctrl_connection.send("CLOSE:" + str(ret)) return True
def lime_receive(data_conn, ctrl_conn, frequency: float, sample_rate: float, bandwidth: float, gain: float, channel_index: int, antenna_index: int): if not LimeSDR.initialize_limesdr(frequency, sample_rate, bandwidth, gain, channel_index, antenna_index, ctrl_conn, is_tx=False): return False exit_requested = False ctrl_conn.send("Initializing stream...") limesdr.setup_stream(LimeSDR.RECV_FIFO_SIZE) ret = limesdr.start_stream() ctrl_conn.send("Initialize stream:{0}".format(ret)) while not exit_requested: limesdr.recv_stream(data_conn, LimeSDR.READ_SAMPLES, LimeSDR.LIME_TIMEOUT_RECEIVE_MS) while ctrl_conn.poll(): result = LimeSDR.process_command(ctrl_conn.recv(), ctrl_conn, is_tx=False) if result == LimeSDR.Command.STOP.name: exit_requested = True break limesdr.stop_stream() limesdr.destroy_stream() LimeSDR.shutdown_lime_sdr(ctrl_conn) data_conn.close() ctrl_conn.close()
def lime_send(ctrl_connection, frequency: float, sample_rate: float, bandwidth: float, gain: float, channel_index: int, antenna_index: int, samples_to_send, current_sent_index, current_sending_repeat, sending_repeats): def sending_is_finished(): if sending_repeats == 0: # 0 = infinity return False return current_sending_repeat.value >= sending_repeats and current_sent_index.value >= len(samples_to_send) if not LimeSDR.initialize_limesdr(frequency, sample_rate, bandwidth, gain, channel_index, antenna_index, ctrl_connection, is_tx=True): return False exit_requested = False num_samples = LimeSDR.SEND_SAMPLES ctrl_connection.send("Initializing stream...") limesdr.setup_stream(LimeSDR.SEND_FIFO_SIZE) ret = limesdr.start_stream() ctrl_connection.send("Initialize stream:{0}".format(ret)) while not exit_requested and not sending_is_finished(): limesdr.send_stream( samples_to_send[current_sent_index.value:current_sent_index.value+num_samples], LimeSDR.LIME_TIMEOUT_SEND_MS ) current_sent_index.value += num_samples if current_sent_index.value >= len(samples_to_send) - 1: current_sending_repeat.value += 1 if current_sending_repeat.value < sending_repeats or sending_repeats == 0: # 0 = infinity current_sent_index.value = 0 else: current_sent_index.value = len(samples_to_send) while ctrl_connection.poll(): result = LimeSDR.process_command(ctrl_connection.recv(), ctrl_connection, is_tx=True) if result == LimeSDR.Command.STOP.name: exit_requested = True break ret = limesdr.stop_stream() logger.debug("LimeSDR: Stop stream: {}".format(ret)) ret = limesdr.destroy_stream() logger.debug("LimeSDR: Destroy stream: {}".format(ret)) LimeSDR.shutdown_lime_sdr(ctrl_connection) ctrl_connection.close()
def test_cython_wrapper(self): print("Devices:", limesdr.get_device_list()) # print("Open:", limesdr.open("LimeSDR-USB, media=USB 3.0, module=STREAM, addr=1d50:6108, serial=0009060B0049180A")) print("Open:", limesdr.open()) print("-" * 20) print("Is Open 0:", limesdr.is_open(0)) print("Is Open 1:", limesdr.is_open(1)) print("Init", limesdr.init()) limesdr.set_tx(True) self.assertTrue(limesdr.get_tx()) #print(limesdr.IS_TX) print("Num Channels TX:", limesdr.get_num_channels()) print("TX antennas", limesdr.get_antenna_list()) limesdr.set_tx(False) self.assertFalse(limesdr.get_tx()) print("Num Channels RX:", limesdr.get_num_channels()) limesdr.CHANNEL = 0 print("Enable RX Channel 0:", limesdr.enable_channel(True, False, 0)) #path = os.path.realpath(os.path.join(__file__, "..", "..", "src", "urh", "dev", "native", "lime.ini")) #print(path) #limesdr.load_config(path) #limesdr.save_config("/tmp/lime_test.ini") clocks = ["LMS_CLOCK_REF", "LMS_CLOCK_SXR", "LMS_CLOCK_SXT", "LMS_CLOCK_CGEN", "LMS_CLOCK_RXTSP", "LMS_CLOCK_TXTSP"] for i, clock in enumerate(clocks): print(clock, limesdr.get_clock_freq(i)) limesdr.print_last_error() print("RX Sample Rate Range:", limesdr.get_sample_rate_range()) print("RX Channel 0 Sample Rate:", limesdr.get_sample_rate()) print("Set Sample Rate:", limesdr.set_sample_rate(2e6)) print("RX Channel 0 Sample Rate:", limesdr.get_sample_rate()) limesdr.print_last_error() print("RX Frequency Range:", limesdr.get_center_frequency_range()) print("RX 0 center freq:", limesdr.get_center_frequency()) print("RX 0 set center freq:", limesdr.set_center_frequency(433.92e6)) print("RX 0 center freq:", limesdr.get_center_frequency()) limesdr.print_last_error() print("RX 0 gain", limesdr.get_normalized_gain()) print("RX 0 set gain", limesdr.set_normalized_gain(0.5)) print("RX 0 gain", limesdr.get_normalized_gain()) limesdr.print_last_error() print("RX Bandwidth Range", limesdr.get_lpf_bandwidth_range()) print("RX 0 Bandwidth", limesdr.get_lpf_bandwidth()) print("RX 0 set Bandwidth", limesdr.set_lpf_bandwidth(20e6)) print("RX 0 Bandwidth", limesdr.get_lpf_bandwidth()) limesdr.print_last_error() print("RX 0 calibrate:", limesdr.calibrate(20e6)) limesdr.print_last_error() antenna_list = limesdr.get_antenna_list() print("RX 0 antenna list", antenna_list) print("RX 0 current antenna", limesdr.get_antenna(), antenna_list[limesdr.get_antenna()]) print("RX 0 current antenna BW", limesdr.get_antenna_bw(limesdr.get_antenna())) print("Chip Temperature", limesdr.get_chip_temperature()) parent_conn, child_conn = Pipe() for _ in range(2): limesdr.print_last_error() print("Setup stream", limesdr.setup_stream(1000)) print("Start stream", limesdr.start_stream()) limesdr.recv_stream(child_conn, 1000, 100) print("Stop stream", limesdr.stop_stream()) print("Destroy stream", limesdr.destroy_stream()) print(parent_conn.recv_bytes()) limesdr.set_tx(True) self.assertTrue(limesdr.get_tx()) samples_to_send = np.ones(32768, dtype=np.complex64) for _ in range(2): limesdr.print_last_error() print("Setup stream", limesdr.setup_stream(4000000000)) print("Start stream", limesdr.start_stream()) print("Send samples", limesdr.send_stream(samples_to_send, 100)) print("Stop stream", limesdr.stop_stream()) print("Destroy stream", limesdr.destroy_stream()) print("-" * 20) print("Close:", limesdr.close()) print("Is Open 0:", limesdr.is_open(0)) print("Is Open 1:", limesdr.is_open(1))
def test_cython_wrapper(self): print("Devices:", limesdr.get_device_list()) # print("Open:", limesdr.open("LimeSDR-USB, media=USB 3.0, module=STREAM, addr=1d50:6108, serial=0009060B0049180A")) print("Open:", limesdr.open()) print("-" * 20) print("Is Open 0:", limesdr.is_open(0)) print("Is Open 1:", limesdr.is_open(1)) print("Init", limesdr.init()) limesdr.set_tx(True) self.assertTrue(limesdr.get_tx()) #print(limesdr.IS_TX) print("Num Channels TX:", limesdr.get_num_channels()) print("TX antennas", limesdr.get_antenna_list()) limesdr.set_tx(False) self.assertFalse(limesdr.get_tx()) print("Num Channels RX:", limesdr.get_num_channels()) limesdr.CHANNEL = 0 print("Enable RX Channel 0:", limesdr.enable_channel(True, False, 0)) #path = os.path.realpath(os.path.join(__file__, "..", "..", "src", "urh", "dev", "native", "lime.ini")) #print(path) #limesdr.load_config(path) #limesdr.save_config("/tmp/lime_test.ini") clocks = [ "LMS_CLOCK_REF", "LMS_CLOCK_SXR", "LMS_CLOCK_SXT", "LMS_CLOCK_CGEN", "LMS_CLOCK_RXTSP", "LMS_CLOCK_TXTSP" ] for i, clock in enumerate(clocks): print(clock, limesdr.get_clock_freq(i)) limesdr.print_last_error() print("RX Sample Rate Range:", limesdr.get_sample_rate_range()) print("RX Channel 0 Sample Rate:", limesdr.get_sample_rate()) print("Set Sample Rate:", limesdr.set_sample_rate(2e6)) print("RX Channel 0 Sample Rate:", limesdr.get_sample_rate()) limesdr.print_last_error() print("RX Frequency Range:", limesdr.get_center_frequency_range()) print("RX 0 center freq:", limesdr.get_center_frequency()) print("RX 0 set center freq:", limesdr.set_center_frequency(433.92e6)) print("RX 0 center freq:", limesdr.get_center_frequency()) limesdr.print_last_error() print("RX 0 gain", limesdr.get_normalized_gain()) print("RX 0 set gain", limesdr.set_normalized_gain(0.5)) print("RX 0 gain", limesdr.get_normalized_gain()) limesdr.print_last_error() print("RX Bandwidth Range", limesdr.get_lpf_bandwidth_range()) print("RX 0 Bandwidth", limesdr.get_lpf_bandwidth()) print("RX 0 set Bandwidth", limesdr.set_lpf_bandwidth(20e6)) print("RX 0 Bandwidth", limesdr.get_lpf_bandwidth()) limesdr.print_last_error() print("RX 0 calibrate:", limesdr.calibrate(20e6)) limesdr.print_last_error() antenna_list = limesdr.get_antenna_list() print("RX 0 antenna list", antenna_list) print("RX 0 current antenna", limesdr.get_antenna(), antenna_list[limesdr.get_antenna()]) print("RX 0 current antenna BW", limesdr.get_antenna_bw(limesdr.get_antenna())) print("Chip Temperature", limesdr.get_chip_temperature()) parent_conn, child_conn = Pipe() for _ in range(2): limesdr.print_last_error() print("Setup stream", limesdr.setup_stream(1000)) print("Start stream", limesdr.start_stream()) limesdr.recv_stream(child_conn, 1000, 100) print("Stop stream", limesdr.stop_stream()) print("Destroy stream", limesdr.destroy_stream()) print(parent_conn.recv_bytes()) limesdr.set_tx(True) self.assertTrue(limesdr.get_tx()) samples_to_send = np.ones(32768, dtype=np.complex64) for _ in range(2): limesdr.print_last_error() print("Setup stream", limesdr.setup_stream(4000000000)) print("Start stream", limesdr.start_stream()) print("Send samples", limesdr.send_stream(samples_to_send, 100)) print("Stop stream", limesdr.stop_stream()) print("Destroy stream", limesdr.destroy_stream()) print("-" * 20) print("Close:", limesdr.close()) print("Is Open 0:", limesdr.is_open(0)) print("Is Open 1:", limesdr.is_open(1))