Exemplo n.º 1
0
 def VarDecimSet(self, index=None):  # set decimation, return sample rate
     if index is None:  # initial call to set decimation before the call to open()
         rate = self.application.vardecim_set  # May be None or from different hardware
         try:
             dec = int(float(self.conf.rx_udp_clock // rate + 0.5))
             self.index = self.decimations.index(dec)
         except:
             try:
                 self.index = self.decimations.index(
                     self.conf.rx_udp_decimation)
             except:
                 self.index = 0
     else:
         self.index = index
     dec = self.decimations[self.index]
     if dec >= 128:
         self.rx_control = dec // 64 - 1  # Second stage decimation less one
         QS.set_sample_bytes(3)
     else:
         self.rx_control = dec // 16 - 1  # Second stage decimation less one
         self.rx_control |= 0b01000000  # Change prescaler to 2 (instead of 8)
         QS.set_sample_bytes(2)
     self.NewUdpStatus()
     return int(float(self.conf.rx_udp_clock) / dec + 0.5)
Exemplo n.º 2
0
    def __init__(self, app, conf):
        BaseHardware.__init__(self, app, conf)
        self.got_udp_status = ''  # status from UDP receiver
        # want_udp_status is a 14-byte string with numbers in little-endian order:
        #	[0:2]		'St'
        #	[2:6]		Rx tune phase
        #	[6:10]		Tx tune phase
        #	[10]		Tx output level 0 to 255
        #	[11]		Tx control bits:
        #		0x01	Enable CW transmit
        #		0x02	Enable all other transmit
        #		0x04	Use the HiQSDR extended IO pins not present in the 2010 QEX ver 1.0
        #		0x08	The key is down (software key)
        #		bits 5 and 4: Transmit sample rate
        #			0b00 48k
        #			0b01 192k
        #			0b10 480k
        #			0b11 8k
        #		0x40	odyssey: Spot button is in use
        #		0x80	odyssey: Mic Boost 20dB
        #	[12]	Rx control bits
        #		bits 5 through 0
        #			Second stage decimation less one, 1-39, six bits
        #		bits 7, 6
        #		0b00	Prescaler 8, 3-byte samples I and Q; 1440 / 6 = 240 samples per UDP packet
        #		0b01	Prescaler 2, 2-byte samples
        #		0b10	Prescaler 40, 3-byte samples
        #		0b11	Prescaler 2, 1-byte samples
        #	[13]	zero or firmware version number
        # The above is used for firmware  version 1.0.
        # Version 1.1 adds eight more bytes for the HiQSDR conntrol ports:
        #	[14]	X1 connector:  Preselect pins 69, 68, 65, 64; Preamp pin 63, Tx LED pin 57
        #	[15]	Attenuator pins 84, 83, 82, 81, 80
        #	[16]	More bits: AntSwitch pin 41 is 0x01
        #	[17:22] The remaining five bytes are sent as zero.
        # Version 1.2 uses the same format as 1.1, but adds the "Qs" command (see below).
        # Version 1.3 adds features needed by the new quisk_vna.py program:
        #	[17]	The sidetone volume 0 to 255
        #	[18:20]	This is vna_count, the number of VNA data points; or zero for normal operation
        #	[20]	The CW delay as specified in the config file
        #	[21]	Control bits:
        #		0x01	Switch on tx mirror on rx for adaptive predistortion
        #	[22:24]	Noise blanker level

        # The "Qs" command is a two-byte UDP packet sent to the control port.  It returns the hardware status
        # as the above string, except that the string starts with "Qs" instead of "St".  Do not send the "Qs" command
        # from Quisk, as it interferes with the "St" command.  The "Qs" command is meant to be used from an
        # external program, such as HamLib or a logging program.

        # When vna_count != 0, we are in VNA mode.  The start frequency is rx_phase, and for each point tx_phase is added
        # to advance the frequency.  A zero sample is added to mark the blocks.  The samples are I and Q averaged at DC.

        self.rx_phase = 0
        self.tx_phase = 0
        self.tx_level = 0
        self.tx_control = 0
        self.rx_control = 0
        QS.set_sample_bytes(3)
        self.vna_count = 0  # VNA scan count; MUST be zero for non-VNA operation
        self.cw_delay = conf.cw_delay
        self.index = 0
        self.mode = None
        self.usingSpot = False
        self.band = None
        self.rf_gain = 0
        self.sidetone_volume = 0  # sidetone volume 0 to 255
        self.repeater_freq = None  # original repeater output frequency
        self.HiQSDR_Connector_X1 = 0
        self.HiQSDR_Attenuator = 0
        self.HiQSDR_Bits = 0
        try:
            if conf.radio_sound_mic_boost:
                self.tx_control = 0x80
        except:
            pass
        if conf.use_rx_udp == 2:  # Set to 2 for the HiQSDR
            self.rf_gain_labels = ('RF 0 dB', 'RF +10', 'RF -10', 'RF -20',
                                   'RF -30')
            self.antenna_labels = ('Ant 1', 'Ant 2')
        self.firmware_version = None  # firmware version is initially unknown
        self.rx_udp_socket = None
        self.vfo_frequency = 0  # current vfo frequency
        self.tx_frequency = 0
        self.decimations = []  # supported decimation rates
        for dec in (40, 20, 10, 8, 5, 4, 2):
            self.decimations.append(dec * 64)
        self.decimations.append(80)
        self.decimations.append(64)
        if self.conf.fft_size_multiplier == 0:
            self.conf.fft_size_multiplier = 6  # Set size needed by VarDecim