[chirp_devel] Baofeng UV-B5 Wide Splits and Cross-Band Programming

Jim Unroe
Sun Apr 26 15:00:34 PDT 2015


Hi All,

This weekend I accidentally discovered that the UV-B5/B6 radios can be
programmed with any frequency split across the band and not just the
69.995 MHz maximum offset when programming from the keypad. In
addition to that, the radio can also be successfully programmed for
cross-band operation.

The following code currently limits CHIRP to programming these radios
with maximun offset of 69.995 MHz in a single band with no checking to
make sure that the offset doesn't put the TX frequency out of the
working band of the radio.

   def validate_memory(self, mem):
        msgs = chirp_common.CloneModeRadio.validate_memory(self, mem)

        if (mem.duplex == "split" and abs(mem.freq - mem.offset) > 69995000) \
                or (mem.duplex in ["+", "-"] and mem.offset > 69995000):
            msgs.append(chirp_common.ValidationError(
                    "Max split is 69.995MHz"))
        return msgs

What I propose to do is change the code to something like the
following. It allows programming any split within the VHF or UHF band
and any cross-band pair of frequencies. If the user programs an Offset
or Split frequency that puts the TX frequency outside of the band
limits, an error is displayed.

    def validate_memory(self, mem):
        msgs = chirp_common.CloneModeRadio.validate_memory(self, mem)

        valid = False
        for lo, hi in VALID_BANDS:
            if mem.duplex == "split":
                freq=chirp_common.format_freq(mem.offset)
                _msg = "Offset %s is out of supported range" % freq
                if lo <= mem.offset < hi:
                    valid = True
                    break
            elif mem.duplex == "-":
                freq=chirp_common.format_freq(mem.offset)
                _msg = "Offset %s is out of supported range" % freq
                if lo <= mem.freq - mem.offset < hi:
                    valid = True
                    break
            elif mem.duplex == "+":
                freq=chirp_common.format_freq(mem.offset)
                _msg = "Offset %s is out of supported range" % freq
                if lo <= mem.freq + mem.offset < hi:
                    valid = True
                    break
            elif not mem.duplex in ["+", "-", "split"]:
                _msg = " "
                if lo <= mem.freq < hi:
                    valid = True
                    break
        if not valid:
            msgs.append(chirp_common.ValidationError(_msg))
        return msgs

My question is...

Is there a more tidy way to code this or should I go ahead and submit
something like this?

Thanks,
Jim KC9HI



More information about the chirp_devel mailing list