def test_set_rx(self): hackrf.setup() hackrf.set_freq(433.92e6) print(hackrf.is_streaming()) hackrf.start_rx_mode(self.callback_fun) time.sleep(1) hackrf.stop_rx_mode()
def hackrf_receive(data_connection, ctrl_connection, freq, sample_rate, bandwidth, gain, if_gain, baseband_gain): def callback_recv(buffer): try: data_connection.send_bytes(buffer) except (BrokenPipeError, EOFError): pass return 0 if not HackRF.initialize_hackrf(freq, sample_rate, bandwidth, gain, if_gain, baseband_gain, ctrl_connection, is_tx=False): return False hackrf.start_rx_mode(callback_recv) exit_requested = False while not exit_requested: while ctrl_connection.poll(): result = HackRF.process_command(ctrl_connection.recv(), ctrl_connection, is_tx=False) if result == "stop": exit_requested = True break HackRF.shutdown_hackrf(ctrl_connection) data_connection.close() ctrl_connection.close()
def start_rx_mode(self): if self.is_open: self.init_recv_buffer() self.set_device_parameters() ret = hackrf.start_rx_mode(self.callback_recv) self.is_receiving = ret == self.success if self.is_receiving: logger.info("HackRF: Starting receiving thread") self._start_read_rcv_buffer_thread() self.log_retcode(ret, "start_rx_mode") else: self.log_retcode(self.error_not_open, "start_rx_mode")
def enter_async_receive_mode(cls, data_connection: Connection): hackrf.start_rx_mode(data_connection.send_bytes)
def enter_async_receive_mode(cls, data_connection: Connection, ctrl_connection: Connection): ret = hackrf.start_rx_mode(data_connection.send_bytes) ctrl_connection.send("Start RX MODE:" + str(ret)) return ret
def enter_async_receive_mode(cls, data_connection: Connection): hackrf.start_rx_mode(data_connection.send_bytes)
def enter_async_receive_mode(cls, data_connection: Connection, ctrl_connection: Connection): ret = hackrf.start_rx_mode(data_connection.send_bytes) ctrl_connection.send("Start RX MODE:" + str(ret)) return ret