예제 #1
0
def process_command(command):
    if command == "stop":
        return "stop"

    tag, value = command.split(":")
    if tag == "center_freq":
        logger.info("[RTLSDR] setting center freq to {}".format(int(value)))
        rtlsdr.set_center_freq(int(value))
    elif tag == "tuner_gain":
        logger.info("[RTLSDR] setting tuner_gain to {}".format(int(value)))
        rtlsdr.set_tuner_gain(int(value))
    elif tag == "sample_rate":
        logger.info("[RTLSDR] setting sample rate to {}".format(int(value)))
        rtlsdr.set_sample_rate(int(value))
예제 #2
0
def process_command(command):
    if command == "stop":
        return "stop"

    tag, value = command.split(":")
    if tag == "center_freq":
        logger.info("[RTLSDR] setting center freq to {}".format(int(value)))
        rtlsdr.set_center_freq(int(value))
    elif tag == "tuner_gain":
        logger.info("[RTLSDR] setting tuner_gain to {}".format(int(value)))
        rtlsdr.set_tuner_gain(int(value))
    elif tag == "sample_rate":
        logger.info("[RTLSDR] setting sample rate to {}".format(int(value)))
        rtlsdr.set_sample_rate(int(value))
예제 #3
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)
예제 #4
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()
예제 #5
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()
예제 #6
0
    def process_command(command):
        logger.debug("RTLSDR: {}".format(command))
        if command == "stop":
            return "stop"

        tag, value = command.split(":")
        if tag == "center_freq":
            logger.info("RTLSDR: Set center freq to {0}".format(int(value)))
            return rtlsdr.set_center_freq(int(value))

        elif tag == "rf_gain":
            logger.info("RTLSDR: Set tuner gain to {0}".format(int(value)))
            return rtlsdr.set_tuner_gain(10 *
                                         int(value))  # calculate *10 for API

        elif tag == "sample_rate":
            logger.info("RTLSDR: Set sample_rate to {0}".format(int(value)))
            return rtlsdr.set_sample_rate(int(value))

        elif tag == "tuner_bandwidth":
            logger.info("RTLSDR: Set bandwidth to {0}".format(int(value)))
            return rtlsdr.set_tuner_bandwidth(int(value))

        elif tag == "freq_correction":
            logger.info("RTLSDR: Set freq_correction to {0}".format(
                int(value)))
            return rtlsdr.set_freq_correction(int(value))

        elif tag == "direct_sampling_mode":
            logger.info("RTLSDR: Set direct_sampling_mode to {0}".format(
                int(value)))
            return rtlsdr.set_direct_sampling(int(value))
예제 #7
0
파일: RTLSDR.py 프로젝트: tariq786/urh
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()
예제 #8
0
파일: RTLSDR.py 프로젝트: tariq786/urh
def process_command(command):
    logger.debug("RTLSDR: {}".format(command))
    if command == "stop":
        return "stop"

    tag, value = command.split(":")
    if tag == "center_freq":
        logger.info("RTLSDR: Set center freq to {0}".format(int(value)))
        return rtlsdr.set_center_freq(int(value))

    elif tag == "tuner_gain":
        logger.info("RTLSDR: Set tuner gain to {0}".format(int(value)))
        return rtlsdr.set_tuner_gain(int(value))

    elif tag == "sample_rate":
        logger.info("RTLSDR: Set sample_rate to {0}".format(int(value)))
        return rtlsdr.set_sample_rate(int(value))

    elif tag == "tuner_bandwidth":
        logger.info("RTLSDR: Set bandwidth to {0}".format(int(value)))
        return rtlsdr.set_tuner_bandwidth(int(value))
예제 #9
0
파일: RTLSDR.py 프로젝트: todd-placher/urh
 def set_device_sample_rate(self, sample_rate):
     ret = rtlsdr.set_sample_rate(int(sample_rate))
     self.log_retcode(ret, "Set sample rate")