[chirp_devel] [PATCH] Add tx freq check

Marco Filippi IZ3GME
Fri May 1 01:11:57 PDT 2015


# HG changeset patch
# User Marco Filippi <iz3gme.marco at gmail.com>
# Date 1430467490 -7200
#      ven mag 01 10:04:50 2015 +0200
# Node ID f3604a6eadfc6e1119bf3dde27572c238f44eec7
# Parent  31a7494c324a347634c30cc3c9bded2ce83eeb21
Add tx freq check

Add TX frequency check to common memory validation routine to ensure it always
fall withing radio supported ranges, including when split is set
Also fix bruteforce test which was using a too low RX freq with - split

Implement #2557

diff --git a/chirp/chirp_common.py b/chirp/chirp_common.py
--- a/chirp/chirp_common.py
+++ b/chirp/chirp_common.py
@@ -924,6 +924,26 @@
                      "of supported range").format(freq=format_freq(mem.freq)))
                 msgs.append(msg)
 
+        if self.valid_bands and \
+                self.valid_duplexes and \
+                mem.duplex in ["split", "-", "+"]:
+            if mem.duplex == "split":
+                freq = mem.offset
+            elif mem.duplex == "-":
+                freq = mem.freq - mem.offset
+            elif mem.duplex == "+":
+                freq = mem.freq + mem.offset
+            valid = False
+            for lo, hi in self.valid_bands:
+                if lo <= freq < hi:
+                    valid = True
+                    break
+            if not valid:
+                msg = ValidationError(
+                        ("Tx freq {freq} is out "
+                         "of supported range").format(freq=format_freq(freq)))
+                msgs.append(msg)
+
         if mem.power and \
                 self.valid_power_levels and \
                 mem.power not in self.valid_power_levels:
diff --git a/tests/run_tests b/tests/run_tests
--- a/tests/run_tests
+++ b/tests/run_tests
@@ -451,7 +451,7 @@
             m = chirp_common.Memory()
             m.number = rf.memory_bounds[0]
             if rf.valid_bands:
-                m.freq = rf.valid_bands[0][0] + 100000
+                m.freq = rf.valid_bands[0][0] + 600000
             else:
                 m.freq = 146520000
             if m.freq < 30000000 and "AM" in rf.valid_modes:



More information about the chirp_devel mailing list