[chirp_devel] [PATCH] [FT1D] Add support for setting backtrack targets - issue #4877
# HG changeset patch # User Angus Ainslie angus@akkea.ca # Date 1496430289 21600 # Fri Jun 02 13:04:49 2017 -0600 # Node ID 678d3f1e4944193d17f9bd6392be2e4270fc7655 # Parent d4222df0000cdde3311e54df02edf80858720316 [FT1D] Add support for setting backtrack targets - issue #4877
diff -r d4222df0000c -r 678d3f1e4944 chirp/drivers/ft1d.py --- a/chirp/drivers/ft1d.py Fri Jun 02 06:21:43 2017 +0900 +++ b/chirp/drivers/ft1d.py Fri Jun 02 13:04:49 2017 -0600 @@ -342,6 +342,30 @@ } aprs_message_pkt[60]; """
+MEM_BACKTRACK_FORMAT = """ +#seekto 0xdf06; +struct { + u8 status; // 01 full 08 empty + u8 reserved0; // 00 + bbcd year; // 17 + bbcd mon; // 06 + bbcd day; // 01 + u8 reserved1; // 06 + bbcd hour; // 21 + bbcd min; // xx + u8 reserved2; // 00 + u8 reserved3; // 00 + char NShemi[1]; + char lat[3]; + char lat_min[2]; + char lat_dec_sec[4]; + char WEhemi[1]; + char lon[3]; + char lon_min[2]; + char lon_dec_sec[4]; +} backtrack[3]; + +""" MEM_CHECKSUM_FORMAT = """ #seekto 0x1FDC9; u8 checksum; @@ -368,7 +392,6 @@ chirp_common.PowerLevel("L2", watts=1.00), chirp_common.PowerLevel("L1", watts=0.05)]
- class FT1Bank(chirp_common.NamedBank): """A FT1D bank"""
@@ -617,7 +640,7 @@
def process_mmap(self): mem_format = MEM_SETTINGS_FORMAT + MEM_FORMAT + MEM_APRS_FORMAT + \ - MEM_CHECKSUM_FORMAT + MEM_BACKTRACK_FORMAT + MEM_CHECKSUM_FORMAT self._memobj = bitwise.parse(mem_format % self._mem_params, self._mmap)
def get_features(self): @@ -1456,6 +1479,140 @@
return menu
+ def _get_backtrack_settings(self): + + menu = RadioSettingGroup( "backtrack", "Backtrack") + + for i in range(3): + prefix = '' + if i == 0 : + prefix = "Star " + if i == 1 : + prefix = "L1 " + if i == 2 : + prefix = "L2 " + + bt_idx = "backtrack[%d]" % i + + bt = self._memobj.backtrack[i] + + val = RadioSettingValueInteger(0, 16, bt.status) + rs = RadioSetting("%s.status" % bt_idx, + prefix + "status", val) + menu.append(rs) + + if bt.status == 1 : + val = RadioSettingValueInteger(0, 99, bt.year) + else : + val = RadioSettingValueInteger(0, 99, 0) + rs = RadioSetting("%s.year" % bt_idx, + prefix + "year", val) + menu.append(rs) + + if bt.status == 1 : + val = RadioSettingValueInteger(0, 12, bt.mon) + else : + val = RadioSettingValueInteger(0, 12, 0) + rs = RadioSetting("%s.mon" % bt_idx, + prefix + "month", val) + menu.append(rs) + + if bt.status == 1 : + val = RadioSettingValueInteger(0, 31, bt.day) + else : + val = RadioSettingValueInteger(0, 31, 0) + rs = RadioSetting("%s.day" % bt_idx, + prefix + "day", val) + menu.append(rs) + + if bt.status == 1 : + val = RadioSettingValueInteger(0, 23, bt.hour) + else : + val = RadioSettingValueInteger(0, 23, 0) + rs = RadioSetting("%s.hour" % bt_idx, + prefix + "hour", val) + menu.append(rs) + + if bt.status == 1 : + val = RadioSettingValueInteger(0, 59, bt.min) + else : + val = RadioSettingValueInteger(0, 59, 0) + rs = RadioSetting("%s.min" % bt_idx, + prefix + "min", val) + menu.append(rs) + + if bt.status == 1 : + val = RadioSettingValueString( 0, 1, str(bt.NShemi)) + else : + val = RadioSettingValueString( 0, 1, ' ') + rs = RadioSetting("%s.NShemi" % bt_idx, prefix + "NS hemisphere", val) + rs.set_apply_callback(self.apply_NShemi, bt ) + menu.append(rs) + + if bt.status == 1 : + val = RadioSettingValueString( 0, 3, str(bt.lat)) + else : + val = RadioSettingValueString( 0, 3, ' ') + rs = RadioSetting("%s.lat" % bt_idx, prefix + "Latitude", val) + #rs.set_apply_callback(self.apply_NShemi, bt ) + menu.append(rs) + + if bt.status == 1 : + val = RadioSettingValueString( + 0, 2, str(bt.lat_min)) + else : + val = RadioSettingValueString( 0, 2, ' ') + rs = RadioSetting("%s.lat_min" % bt_idx, prefix + "Latitude Minutes", val) + #rs.set_apply_callback(self.apply_NShemi, bt ) + menu.append(rs) + + if bt.status == 1 : + val = RadioSettingValueString( + 0, 4, str(bt.lat_dec_sec)) + else : + val = RadioSettingValueString( 0, 4, ' ') + rs = RadioSetting("%s.lat_dec_sec" % bt_idx, prefix + "Latitude Decimal Seconds", val) + #rs.set_apply_callback(self.apply_NShemi, bt ) + menu.append(rs) + + if bt.status == 1 : + val = RadioSettingValueString( + 0, 1, str(bt.WEhemi)) + else : + val = RadioSettingValueString( 0, 1, ' ') + rs = RadioSetting("%s.WEhemi" % bt_idx, prefix + "WE hemisphere", val) + rs.set_apply_callback(self.apply_WEhemi, bt ) + menu.append(rs) + + if bt.status == 1 : + val = RadioSettingValueString( + 0, 3, str(bt.lon)) + else : + val = RadioSettingValueString( 0, 3, ' ') + rs = RadioSetting("%s.lon" % bt_idx, prefix + "Longitude", val) + #rs.set_apply_callback(self.apply_NShemi, bt ) + menu.append(rs) + + if bt.status == 1 : + val = RadioSettingValueString( + 0, 2, str(bt.lon_min)) + else : + val = RadioSettingValueString( 0, 2, ' ') + rs = RadioSetting("%s.lon_min" % bt_idx, prefix + "Longitude Minutes", val) + #rs.set_apply_callback(self.apply_NShemi, bt ) + menu.append(rs) + + if bt.status == 1 : + val = RadioSettingValueString( + 0, 4, str(bt.lon_dec_sec)) + else : + val = RadioSettingValueString( 0, 4, ' ') + rs = RadioSetting("%s.lon_dec_sec" % bt_idx, prefix + "Longitude Decimal Seconds", val) + #rs.set_apply_callback(self.apply_NShemi, bt ) + menu.append(rs) + + return menu + def _get_scan_settings(self): menu = RadioSettingGroup("scan_settings", "Scan") scan_settings = self._memobj.scan_settings @@ -1536,7 +1693,8 @@ self._get_aprs_beacons(), self._get_dtmf_settings(), self._get_misc_settings(), - self._get_scan_settings()) + self._get_scan_settings(), + self._get_backtrack_settings()) return top
def get_settings(self): @@ -1691,3 +1849,17 @@ for x in range(len(val), 16): val.append(0xFF) cls._memobj.dtmf[i].memory = val + + def apply_NShemi(cls, setting, obj ): + hemi = setting.value.get_value().upper() + + if hemi != 'N' and hemi != 'S' : + hemi = ' ' + setattr(obj, "NShemi", hemi ) + + def apply_WEhemi(cls, setting, obj ): + hemi = setting.value.get_value().upper() + + if hemi != 'W' and hemi != 'E' : + hemi = ' ' + setattr(obj, "WEhemi", hemi )
# HG changeset patch # User Angus Ainslie angus@akkea.ca # Date 1496430289 21600 # Fri Jun 02 13:04:49 2017 -0600 # Node ID 678d3f1e4944193d17f9bd6392be2e4270fc7655 # Parent d4222df0000cdde3311e54df02edf80858720316 [FT1D] Add support for setting backtrack targets - issue #4877
This broke:
Yaesu FT-1D R Settings FAILED: Invalid Radio Settings
Can you fix it up quick? If not, I can revert this, but I'd rather just roll forward if possible.
Thanks!
--Dan
On 2017-06-02 17:58, Dan Smith via chirp_devel wrote:
# HG changeset patch # User Angus Ainslie angus@akkea.ca # Date 1496430289 21600 # Fri Jun 02 13:04:49 2017 -0600 # Node ID 678d3f1e4944193d17f9bd6392be2e4270fc7655 # Parent d4222df0000cdde3311e54df02edf80858720316 [FT1D] Add support for setting backtrack targets - issue #4877
This broke:
Yaesu FT-1D R Settings FAILED: Invalid Radio Settings
Can you fix it up quick? If not, I can revert this, but I'd rather just roll forward if possible.
Sorry , I ran the tests but didn't notice it failed until after I pushed.
I'll get a chance to fix it later today so should be able to push by tomorrow morning. Is that quick enough ?
On 2017-06-03 08:37, Dan Smith via chirp_devel wrote:
I'll get a chance to fix it later today so should be able to push by tomorrow morning. Is that quick enough ?
Yep, thanks!
So I'd like to fix this but the tests are doing something I don't understand. Why is the test trying to program an out of bounds value ?
ERROR: Failed to parse settings: Traceback (most recent call last): File "../chirp/drivers/ft1d.py", line 1702, in get_settings return self._get_settings() File "../chirp/drivers/ft1d.py", line 1697, in _get_settings self._get_backtrack_settings()) File "../chirp/drivers/ft1d.py", line 1505, in _get_backtrack_settings val = RadioSettingValueInteger(0, 99, bt.year) File "../chirp/settings.py", line 83, in __init__ self.set_value(current) File "../chirp/settings.py", line 92, in set_value (value, self._min, self._max)) InvalidValueError: Value 165 not in range 0-99
Yaesu FT-1D R Settings FAILED: Invalid Radio Settings
So I'd like to fix this but the tests are doing something I don't understand. Why is the test trying to program an out of bounds value ?
ERROR: Failed to parse settings: Traceback (most recent call last): File "../chirp/drivers/ft1d.py", line 1702, in get_settings return self._get_settings() File "../chirp/drivers/ft1d.py", line 1697, in _get_settings self._get_backtrack_settings()) File "../chirp/drivers/ft1d.py", line 1505, in _get_backtrack_settings val = RadioSettingValueInteger(0, 99, bt.year) File "../chirp/settings.py", line 83, in __init__ self.set_value(current) File "../chirp/settings.py", line 92, in set_value (value, self._min, self._max)) InvalidValueError: Value 165 not in range 0-99
Yaesu FT-1D R Settings FAILED: Invalid Radio Settings
This is because "year" can only contain values from 0 through 99 and the test image has a value of 165 which is out-of-tange.
+ if bt.status == 1 : + val = RadioSettingValueInteger(0, 99, bt.year) + else : + val = RadioSettingValueInteger(0, 99, 0) + rs = RadioSetting("%s.year" % bt_idx, + prefix + "year", val) + menu.append(rs) +
You can do something here to trap values that are over 99 and do something else.
Jim
On 2017-06-03 18:14, Jim Unroe wrote:
So I'd like to fix this but the tests are doing something I don't understand. Why is the test trying to program an out of bounds value ?
ERROR: Failed to parse settings: Traceback (most recent call last): File "../chirp/drivers/ft1d.py", line 1702, in get_settings return self._get_settings() File "../chirp/drivers/ft1d.py", line 1697, in _get_settings self._get_backtrack_settings()) File "../chirp/drivers/ft1d.py", line 1505, in _get_backtrack_settings val = RadioSettingValueInteger(0, 99, bt.year) File "../chirp/settings.py", line 83, in __init__ self.set_value(current) File "../chirp/settings.py", line 92, in set_value (value, self._min, self._max)) InvalidValueError: Value 165 not in range 0-99
Yaesu FT-1D R Settings FAILED: Invalid Radio Settings
This is because "year" can only contain values from 0 through 99 and the test image has a value of 165 which is out-of-tange.
OK I made the assumption the test would only try valid values.
if bt.status == 1 :
val = RadioSettingValueInteger(0, 99, bt.year)
else :
val = RadioSettingValueInteger(0, 99, 0)
rs = RadioSetting("%s.year" % bt_idx,
prefix + "year", val)
menu.append(rs)
You can do something here to trap values that are over 99 and do something else.
Is there some way to have a popup or some message to the user that I could trigger when this happens ?
OK I made the assumption the test would only try valid values.
I don't think the tests are trying invalid values, an invalid value is being loaded from the image and saved incidentally, right?
Is there some way to have a popup or some message to the user that I could trigger when this happens ?
Presumably 165 is an invalid value right? Maybe it means "unset" ?
In either case, it'd be best (i.e. most consistent with other drivers) to just load a default if the stored value is out of range.
--Dan
participants (3)
-
Angus Ainslie
-
Dan Smith
-
Jim Unroe