Exemplo n.º 1
0
    def test_cython_wrapper(self):

        print("Device count:", rtlsdr.get_device_count())
        print("Device name:", rtlsdr.get_device_name(0))
        manufact, product, serial = rtlsdr.get_device_usb_strings(0)
        print("Manufacturer:", manufact)
        print("Product:", product)
        print("Serial", serial)
        print("Index by serial", rtlsdr.get_index_by_serial(serial))
        print("Open:", rtlsdr.open(0))
        print("Reset Buffer:", rtlsdr.reset_buffer())  # IMPORTANT
        print("XTAL Freq:", rtlsdr.get_xtal_freq())
        print("USB device strings", rtlsdr.get_usb_strings())
        print("Center Freq:", rtlsdr.get_center_freq())
        print("Set center freq to 433MHz", rtlsdr.set_center_freq(int(433e6)))
        print("Center Freq:", rtlsdr.get_center_freq())
        print("Freq Correction", rtlsdr.get_freq_correction())
        print("Set Freq Correction to 10", rtlsdr.set_freq_correction(10))
        print("Freq Correction", rtlsdr.get_freq_correction())
        print("tuner type", rtlsdr.get_tuner_type())
        print("tuner_gains", rtlsdr.get_tuner_gains())
        print("set_manual_gain_mode", rtlsdr.set_tuner_gain_mode(1))
        print("tuner gain", rtlsdr.get_tuner_gain())
        print("set gain to 338", rtlsdr.set_tuner_gain(338))
        print("tuner gain", rtlsdr.get_tuner_gain())
        print("set tuner if gain", rtlsdr.set_tuner_if_gain(1, 10))
        print("Sample Rate", rtlsdr.get_sample_rate())
        print("Set Sample Rate to 300k", rtlsdr.set_sample_rate(300 * 10 ** 3))
        print("Sample Rate", rtlsdr.get_sample_rate())
        read_samples = rtlsdr.read_sync(1024)
        print(read_samples)
        rtlsdr.close()
Exemplo n.º 2
0
    def test_cython_wrapper(self):

        print("Device count:", rtlsdr.get_device_count())
        print("Device name:", rtlsdr.get_device_name(0))
        manufact, product, serial = rtlsdr.get_device_usb_strings(0)
        print("Manufacturer:", manufact)
        print("Product:", product)
        print("Serial", serial)
        print("Index by serial", rtlsdr.get_index_by_serial(serial))
        print("Open:", rtlsdr.open(0))
        print("Reset Buffer:", rtlsdr.reset_buffer())  # IMPORTANT
        print("XTAL Freq:", rtlsdr.get_xtal_freq())
        print("USB device strings", rtlsdr.get_usb_strings())
        print("Center Freq:", rtlsdr.get_center_freq())
        print("Set center freq to 433MHz", rtlsdr.set_center_freq(int(433e6)))
        print("Center Freq:", rtlsdr.get_center_freq())
        print("Freq Correction", rtlsdr.get_freq_correction())
        print("Set Freq Correction to 10", rtlsdr.set_freq_correction(10))
        print("Freq Correction", rtlsdr.get_freq_correction())
        print("tuner type", rtlsdr.get_tuner_type())
        print("tuner_gains", rtlsdr.get_tuner_gains())
        print("set_manual_gain_mode", rtlsdr.set_tuner_gain_mode(1))
        print("tuner gain", rtlsdr.get_tuner_gain())
        print("set gain to 338", rtlsdr.set_tuner_gain(338))
        print("tuner gain", rtlsdr.get_tuner_gain())
        print("set tuner if gain", rtlsdr.set_tuner_if_gain(1, 10))
        print("Sample Rate", rtlsdr.get_sample_rate())
        print("Set Sample Rate to 300k", rtlsdr.set_sample_rate(300 * 10 ** 3))
        print("Sample Rate", rtlsdr.get_sample_rate())
        read_samples = rtlsdr.read_sync(1024)
        print(read_samples)
        rtlsdr.close()
Exemplo n.º 3
0
    def receive_sync(data_connection, ctrl_connection, device_number: int, center_freq: int, sample_rate: int,
                     gain: int):
        ret = rtlsdr.open(device_number)
        ctrl_connection.send("open:" + str(ret))

        ret = rtlsdr.set_center_freq(center_freq)
        ctrl_connection.send("set_center_freq:" + str(ret))

        ret = rtlsdr.set_sample_rate(sample_rate)
        ctrl_connection.send("set_sample_rate:" + str(ret))

        ret = rtlsdr.set_tuner_gain(gain)
        ctrl_connection.send("set_tuner_gain:" + str(ret))

        ret = rtlsdr.reset_buffer()
        ctrl_connection.send("reset_buffer:" + str(ret))

        exit_requested = False

        while not exit_requested:
            while ctrl_connection.poll():
                result = RTLSDR.process_command(ctrl_connection.recv())
                if result == "stop":
                    exit_requested = True
                    break

            if not exit_requested:
                data_connection.send_bytes(rtlsdr.read_sync())

        logger.debug("RTLSDR: closing device")
        ret = rtlsdr.close()
        ctrl_connection.send("close:" + str(ret))

        data_connection.close()
        ctrl_connection.close()
Exemplo n.º 4
0
def receive_sync(connection, device_number: int, center_freq: int,
                 sample_rate: int, gain: int):
    rtlsdr.open(device_number)
    rtlsdr.set_center_freq(center_freq)
    rtlsdr.set_sample_rate(sample_rate)
    rtlsdr.set_tuner_gain(gain)
    rtlsdr.reset_buffer()
    exit_requested = False

    while not exit_requested:
        while connection.poll():
            result = process_command(connection.recv())
            if result == "stop":
                exit_requested = True
                break

        if not exit_requested:
            connection.send_bytes(rtlsdr.read_sync())

    logger.debug("RTLSDR: closing device")
    rtlsdr.close()
    connection.close()
Exemplo n.º 5
0
    def receive_sync(data_connection, ctrl_connection, device_number: int,
                     center_freq: int, sample_rate: int, bandwidth: int,
                     gain: int, freq_correction: int,
                     direct_sampling_mode: int):
        ret = rtlsdr.open(device_number)
        ctrl_connection.send("OPEN:" + str(ret))

        RTLSDR.process_command(
            (RTLSDR.Command.SET_FREQUENCY.name, center_freq), ctrl_connection,
            False)
        RTLSDR.process_command(
            (RTLSDR.Command.SET_SAMPLE_RATE.name, sample_rate),
            ctrl_connection, False)
        if RTLSDR.get_bandwidth_is_adjustable():
            RTLSDR.process_command(
                (RTLSDR.Command.SET_BANDWIDTH.name, bandwidth),
                ctrl_connection, False)
        RTLSDR.process_command(
            (RTLSDR.Command.SET_FREQUENCY_CORRECTION.name, freq_correction),
            ctrl_connection, False)
        RTLSDR.process_command((RTLSDR.Command.SET_DIRECT_SAMPLING_MODE.name,
                                direct_sampling_mode), ctrl_connection, False)
        # Gain has to be set last, otherwise it does not get considered by RTL-SDR
        RTLSDR.process_command((RTLSDR.Command.SET_RF_GAIN.name, 10 * gain),
                               ctrl_connection, False)

        ret = rtlsdr.reset_buffer()
        ctrl_connection.send("RESET_BUFFER:" + str(ret))

        exit_requested = False

        while not exit_requested:
            while ctrl_connection.poll():
                result = RTLSDR.process_command(ctrl_connection.recv(),
                                                ctrl_connection, False)
                if result == RTLSDR.Command.STOP.name:
                    exit_requested = True
                    break

            if not exit_requested:
                data_connection.send_bytes(rtlsdr.read_sync())

        logger.debug("RTLSDR: closing device")
        ret = rtlsdr.close()
        ctrl_connection.send("CLOSE:" + str(ret))

        data_connection.close()
        ctrl_connection.close()
Exemplo n.º 6
0
 def shutdown_device(cls, ctrl_connection, is_tx: bool):
     logger.debug("RTLSDR: closing device")
     ret = rtlsdr.close()
     ctrl_connection.send("CLOSE:" + str(ret))
Exemplo n.º 7
0
 def shutdown_device(cls, ctrl_connection, is_tx: bool):
     logger.debug("RTLSDR: closing device")
     ret = rtlsdr.close()
     ctrl_connection.send("CLOSE:" + str(ret))
Exemplo n.º 8
0
 def close(self):
     rtlsdr.close()