egzumer / uvk5-chirp-driver

Quanscheng UV-K5 radio CHIRP driver for Egzumer firmware
https://github.com/egzumer/uv-k5-firmware-custom
Creative Commons Attribution Share Alike 4.0 International
89 stars 13 forks source link

Problem with proper setting freq. to RX only. #6

Closed ResqIT closed 11 months ago

ResqIT commented 11 months ago

In current driver version only " ", "+" and "-" is possible in "Duplex" setting making it impossible to set Channel in RX mode only. Default Quansheng UV-K5 driver (from chirp) has additional off option. When loading configuration from radio, previously configured to be RX only channels have Duplex "-" and offset set to frequency itself. When trying to change anything Error: "Tx freq 0.000000 is out of supported range" is shown

ResqIT commented 11 months ago

in [chirp] (https://github.com/kk7ds/chirp/tree/master/chirp/drivers/uvk5.py): in line 686: rf.valid_duplexes = ["", "-", "+", "off"]

lines 730-757: def validate_memory(self, mem): msgs = super().validate_memory(mem)

    if mem.duplex == 'off':
        return msgs

    # find tx frequency
    if mem.duplex == '-':
        txfreq = mem.freq - mem.offset
    elif mem.duplex == '+':
        txfreq = mem.freq + mem.offset
    else:
        txfreq = mem.freq

    # find band
    band = _find_band(self._expanded_limits, txfreq)
    if band is False:
        msg = "Transmit frequency %.4f MHz is not supported by this radio"\
               % (txfreq/1000000.0)
        msgs.append(chirp_common.ValidationError(msg))

    band = _find_band(self._expanded_limits, mem.freq)
    if band is False:
        msg = "The frequency %.4f MHz is not supported by this radio" \
               % (mem.freq/1000000.0)
        msgs.append(chirp_common.ValidationError(msg))

    return msgs

in lines 921-934: if (mem.offset == 0): mem.duplex = '' else: if _mem.shift == FLAGS1_OFFSET_MINUS: if _mem.freq == _mem.offset:

fake tx disable by setting tx to 0 MHz

                mem.duplex = 'off'
                mem.offset = 0
            else:
                mem.duplex = '-'
        elif _mem.shift == FLAGS1_OFFSET_PLUS:
            mem.duplex = '+'
        else:
            mem.duplex = ''

in 1994-2004: if mem.duplex == "": _mem.offset = 0 _mem.shift = 0 elif mem.duplex == '-': _mem.shift = FLAGS1_OFFSET_MINUS elif mem.duplex == '+': _mem.shift = FLAGS1_OFFSET_PLUS elif mem.duplex == 'off':

we fake tx disable by setting the tx freq to 0 MHz

        _mem.shift = FLAGS1_OFFSET_MINUS
        _mem.offset = _mem.freq
egzumer commented 11 months ago

I don't like the concept. What duplex has to do with TX disable, and what duplex==OFF mean? I would rather add that to TX power, but that is for another day.

For now I changed it so it will accept offset to 0 MHz.

egzumer commented 11 months ago

Although is duplex OFF a standard way in CHIRP to disable TX or is it K5 driver creator invention?

egzumer commented 11 months ago

It looks like it is CHIRP standard way...

ResqIT commented 11 months ago

based on https://www.miklor.com/COM/UV_CHIRP_Examples.php and https://chirp.danplanet.com/projects/chirp/wiki/FAQ there were options of "(None)","+","-","split","off" described... I know it might not be the best way to achive tx block, nevertheless thanks very much for taking it into account.

egzumer commented 11 months ago

In case you didn't notice I added what you asked for, if that is how the CHIRP intends to do it then I'm not gonna argue.