Project

General

Profile

Actions

DevelopersDriverNotes » History » Revision 1

Revision 1/2 | Next »
Dan Smith, 09/17/2024 04:29 PM


This is a set of notes about complex driver situations to help with consistency.

Implied modes

Some radios have an annoying behavior where they determine the mode for a channel based on frequency. This is most commonly used to allow AM for airband frequencies, where the radio does not actually store a bit for "mode is AM" but instead just forces the receiver into AM mode in that range.

Using the airband example, this should be handled by the driver with the following steps:

  • Expose AM as an option in valid_modes.
  • Coerce the Memory.mode value to AM when the frequency is with in the airband range.
  • Implement validate_memory() to check that Memory.mode is AM in the airband range, and FM in all other ranges. If there is a mismatch, return a chirp_common.ValidationWarning to indicate to the user that the mismatch will be corrected by the driver.

Here is an example validate_memory() implementation. Try to re-use the same exact strings to minimize translation overhead:

    AIRBAND = (118000000, 136000000)
    def validate_memory(self, mem):
        msgs = []
        in_range = chirp_common.in_range
        if in_range(mem.freq, [AIRBAND]) and not mem.mode == 'AM':
            msgs.append(chirp_common.ValidationWarning(
                _('Frequency in this range requires AM mode')))
        if not in_range(mem.freq, [AIRBAND]) and mem.mode == 'AM':
            msgs.append(chirp_common.ValidationWarning(
                _('Frequency in this range must not be AM mode')))
        return msgs + super().validate_memory(mem)

Immutable memory fields

Immutable fields on a memory can be implemented by setting, for example, mem.immutable = ['mode'] to prevent the mode from being changed. This should be used in cases where the radio has a special memory that has some required settings. Examples of where this is used:

  • Some radios have a per-mode "call" special channel (i.e. FM, DV, etc)
  • Some radios have requirements that the first 22 channels be the GMRS channels where the name and power level are changeable by the user, but the frequency/duplex are not

Effectively, the decision to mark a field as immutable should generally come down to "is this immutable because of the location of the memory. If the fixed nature is related to other content of the memory (i.e. channels in the airband range must be AM, see above), then it's best to use validate_memory() to check/warn about a required value.

Updated by Dan Smith 3 months ago · 1 revisions