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

Marco Filippi IZ3GME
Mon Apr 27 00:39:31 PDT 2015


Hi Jim

I would write the code this way (WARNING untested code)

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

         if mem.duplex == "split":
             freq = mem.offset
         elif mem.duplex == "-":
             freq = mem.freq - mem.offset
         elif mem.duplex == "+":
             freq = mem.freq + mem.offset
         else:
             msgs.append(chirp_common.ValidationError(" "))
             return msgs

         valid = False
         for lo, hi in VALID_BANDS:
             if lo <= freq < hi:
                 valid = True
                 break

         if not valid:
             _msg = _("Tx freq  %s is out of supported range") %
                 chirp_common.format_freq(freq)
             msgs.append(chirp_common.ValidationError(_msg))

         return msgs


We can also think to add this to RadioFeatures.validate_memory as I 
suppose it's a valid check to be done for any radio that support split.

73 de IZ3GME Marco

On 27/04/2015 00:00, Jim Unroe wrote:
> 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
> _______________________________________________
> chirp_devel mailing list
> chirp_devel at intrepid.danplanet.com
> http://intrepid.danplanet.com/mailman/listinfo/chirp_devel
> Developer docs: http://chirp.danplanet.com/projects/chirp/wiki/Developers
>




More information about the chirp_devel mailing list