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

Jim Unroe
Wed Apr 29 03:33:53 PDT 2015


I didn't get to this until late (too late) last night. I should have
waited until today after work because I can tell that I will pay for
it at work today. ;-)

>  > And I'm not sure if the "_" prior to the "(" is
>> intentional or a typo.
>
> It's intentional: it invokes the translation funtion for the string,
> IMHO all strings visible to users should be passed to _

I will check into this more to hopefully understand how this works. I
just thought the _ was a convention and didn't realize it was being
passed to anything. Thanks for the heads up.


>> The one thing I noticed, and I may be overlooking something, is that
>> when invoking "     def validate_memory(self, mem):" locally, it seems
>> to replace the "common" one. That's why I had code to check the Rx
>> frequency as well. This seems to let me enter any Rx frequency.
>
> That's strange: in your validate_memory you call
> chirp_common.CloneModeRadio.validate_memory which should check for the
> rx freq to be withing ranges.

Yes. If I key in 600. which is out of range, there is no error to the
user. The row is greyed out an unusable, but no error.

In the command window there is this error: "UnboundLocalError: local
variable 'freq' referenced before assignment"

I will repeat the current code below...

    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
        elif mem.duplex != "":
            msgs.append(chirp_common.ValidationError(
                _("Invalid duplex %s") % mem.duplex))
            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

I believe that none of the initial if/elif statements are matched so
when the code reaches " if lo <= freq < hi:", the variable "freq"
hasn't been referenced.

There is also nothing to deal with when Duplex is set to "off"

I don't know if I will have time to look into this further after work
tonight, but I will try.

Thanks for you input and ideas with this Marco. I like where it is going.

Jim KC9HI



More information about the chirp_devel mailing list