changeset:   2007:479d3792d56a
tag:         aprs_settings
tag:         qbase
tag:         qtip
tag:         tip
user:        Sean Burford <sburford@google.com>
date:        Fri May 17 06:45:34 2013 +1000
summary:     [VX8] Add APRS settings menu

diff -r 071742096344 -r 479d3792d56a chirp/chirp_common.py
--- a/chirp/chirp_common.py	Sun May 12 20:37:14 2013 +0200
+++ b/chirp/chirp_common.py	Fri May 17 06:45:34 2013 +1000
@@ -96,6 +96,52 @@
     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1234567890"
 CHARSET_ASCII = "".join([chr(x) for x in range(ord(" "), ord("~")+1)])
 
+# http://aprs.org/aprs11/SSIDs.txt
+APRS_SSID = (
+    "0 Your primary station usually fixed and message capable",
+    "1 generic additional station, digi, mobile, wx, etc",
+    "2 generic additional station, digi, mobile, wx, etc",
+    "3 generic additional station, digi, mobile, wx, etc",
+    "4 generic additional station, digi, mobile, wx, etc",
+    "5 Other networks (Dstar, Iphones, Androids, Blackberry's etc)",
+    "6 Special activity, Satellite ops, camping or 6 meters, etc",
+    "7 walkie talkies, HT's or other human portable",
+    "8 boats, sailboats, RV's or second main mobile",
+    "9 Primary Mobile (usually message capable)",
+    "10 internet, Igates, echolink, winlink, AVRS, APRN, etc",
+    "11 balloons, aircraft, spacecraft, etc",
+    "12 APRStt, DTMF, RFID, devices, one-way trackers*, etc",
+    "13 Weather stations",
+    "14 Truckers or generally full time drivers",
+    "15 generic additional station, digi, mobile, wx, etc")
+APRS_POSITION_COMMENT = (
+    "off duty", "en route", "in service", "returning", "committed",
+    "special", "priority", "custom 0", "custom 1", "custom 2", "custom 3",
+    "custom 4", "custom 5", "custom 6", "EMERGENCY")
+# http://aprs.org/symbols/symbolsX.txt
+APRS_SYMBOLS = (
+    "Police/Sheriff", "[reserved]", "Digi", "Phone", "DX Cluster",
+    "HF Gateway", "Small Aircraft", "Mobile Satellite Groundstation",
+    "Wheelchair", "Snowmobile", "Red Cross", "Boy Scouts", "House QTH (VHF)",
+    "X", "Red Dot", "0 in Circle", "1 in Circle", "2 in Circle",
+    "3 in Circle", "4 in Circle", "5 in Circle", "6 in Circle", "7 in Circle",
+    "8 in Circle", "9 in Circle", "Fire", "Campground", "Motorcycle",
+    "Railroad Engine", "Car", "File Server", "Hurricane Future Prediction",
+    "Aid Station", "BBS or PBBS", "Canoe", "[reserved]", "Eyeball",
+    "Tractor/Farm Vehicle", "Grid Square", "Hotel", "TCP/IP", "[reserved]",
+    "School", "PC User", "MacAPRS", "NTS Station", "Balloon", "Police", "TBD",
+    "Recreational Vehicle", "Space Shuttle", "SSTV", "Bus", "ATV",
+    "National WX Service Site", "Helicopter", "Yacht/Sail Boat", "WinAPRS",
+    "Human/Person", "Triangle", "Mail/Postoffice", "Large Aircraft",
+    "WX Station", "Dish Antenna", "Ambulance", "Bicycle",
+    "Incident Command Post", "Dual Garage/Fire Dept", "Horse/Equestrian",
+    "Fire Truck", "Glider", "Hospital", "IOTA", "Jeep", "Truck", "Laptop",
+    "Mic-Repeater", "Node", "Emergency Operations Center", "Rover (dog)",
+    "Grid Square above 128m", "Repeater", "Ship/Power Boat", "Truck Stop",
+    "Truck (18 wheeler)", "Van", "Water Station", "X-APRS", "Yagi at QTH",
+    "TDB", "[reserved]"
+)
+
 def watts_to_dBm(watts):
     """Converts @watts in watts to dBm"""
     return int(10 * math.log10(int(watts * 1000)))
diff -r 071742096344 -r 479d3792d56a chirp/settings.py
--- a/chirp/settings.py	Sun May 12 20:37:14 2013 +0200
+++ b/chirp/settings.py	Fri May 17 06:45:34 2013 +1000
@@ -200,7 +200,7 @@
     def _validate(self, element):
         # RadioSettingGroup can only contain RadioSettingGroup objects
         if not isinstance(element, RadioSettingGroup):
-            raise InternalError("Incorrect type")
+            raise InternalError("Incorrect type %s" % type(element))
 
     def __init__(self, name, shortname, *elements):
         self._name = name           # Setting identifier
diff -r 071742096344 -r 479d3792d56a chirp/vx8.py
--- a/chirp/vx8.py	Sun May 12 20:37:14 2013 +0200
+++ b/chirp/vx8.py	Fri May 17 06:45:34 2013 +1000
@@ -13,8 +13,14 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import os
+import re
+
 from chirp import chirp_common, yaesu_clone, directory
 from chirp import bitwise
+from chirp.settings import RadioSettingGroup, RadioSetting
+from chirp.settings import RadioSettingValueInteger, RadioSettingValueString
+from chirp.settings import RadioSettingValueList, RadioSettingValueBoolean
 
 MEM_FORMAT = """
 #seekto 0x54a;
@@ -107,6 +113,156 @@
   u8 unknown7[3];
 } memory[900];
 
+#seekto 0xC0CA;
+struct {
+  u8 unknown0:6,
+     rx_baud:2;
+  u8 unknown1:4,
+     tx_delay:4;
+  u8 custom_symbol;
+  u8 unknown2;
+  struct {
+    char callsign[6];
+    u8 ssid;
+  } my_callsign;
+  u8 unknown3:4,
+     selected_position_comment:4;
+  u8 unknown4;
+  u8 set_time_manually:1,
+     tx_interval_beacon:1,
+     ring_beacon:1,
+     ring_msg:1,
+     aprs_mute:1,
+     unknown6:1,
+     tx_smartbeacon:1,
+     af_dual:1;
+  u8 unknown7:1,
+     aprs_units_wind_mph:1,
+     aprs_units_rain_inch:1,
+     aprs_units_temperature_f:1
+     aprs_units_altitude_ft:1,
+     unknown8:1,
+     aprs_units_distance_m:1,
+     aprs_units_position_mmss:1;
+  u8 unknown9:6,
+     aprs_units_speed:2;
+  u8 unknown11:1,
+     filter_other:1,
+     filter_status:1,
+     filter_item:1,
+     filter_object:1,
+     filter_weather:1,
+     filter_position:1,
+     filter_mic_e:1;
+  u8 unknown12:2,
+     timezone:6;
+  u8 unknown13:4,
+     beacon_interval:4;
+  u8 unknown14;
+  u8 unknown15:7,
+     latitude_sign:1;
+  u8 latitude_degree;
+  u8 latitude_minute;
+  u8 latitude_second;
+  u8 unknown16:7,
+     longitude_sign:1;
+  u8 longitude_degree;
+  u8 longitude_minute;
+  u8 longitude_second;
+  u8 unknown17:4,
+     selected_position:4;
+  u8 unknown18:5,
+     selected_beacon_status_txt:3;
+  u8 unknown19:6,
+     gps_units_altitude_ft:1,
+     gps_units_position_sss:1;
+  u8 unknown20:6,
+     gps_units_speed:2;
+  u8 unknown21[4];
+  struct {
+    struct {
+      char callsign[6];
+      u8 ssid;
+    } entry[8];
+  } digi_path_7;
+  u8 unknown22[2];
+  struct {
+    char padded_string[16];
+  } message_macro[7];
+  u8 unknown23:5,
+     selected_msg_group:3;
+  u8 unknown24;
+  struct {
+    char padded_string[9];
+  } msg_group[8];
+  u8 unknown25[4];
+  u8 active_smartbeaconing;
+  struct {
+    u8 low_speed_mph;
+    u8 high_speed_mph;
+    u8 slow_rate_min;
+    u8 fast_rate_sec;
+    u8 turn_angle;
+    u8 turn_slop;
+    u8 turn_time_sec;
+  } smartbeaconing_profile[3];
+  u8 unknown26:2,
+     flash_msg:6;
+  u8 unknown27:2,
+     flash_grp:6;
+  u8 unknown28:2,
+     flash_bln:6;
+  u8 selected_digi_path;
+  struct {
+    struct {
+      char callsign[6];
+      u8 ssid;
+    } entry[2];
+  } digi_path_3_6[4];
+  u8 unknown30:6,
+     selected_my_symbol:2;
+  u8 unknown31[3];
+  u8 unknown32:2,
+     vibrate_msg:6;
+  u8 unknown33:2,
+     vibrate_grp:6;
+  u8 unknown34:2,
+     vibrate_bln:6;
+} aprs;
+
+#seekto 0x%04X;
+struct {
+  bbcd date[3];
+  u8 unknown1;
+  bbcd time[2];
+  u8 sequence;
+  u8 unknown2;
+  u8 sender_callsign[7];
+  u8 data_type;
+  u8 yeasu_data_type;
+  u8 unknown3;
+  u8 unknown4:1,
+     callsign_is_ascii:1,
+     unknown5:6;
+  u8 unknown6;
+  u16 pkt_len;
+  u16 in_use;
+} aprs_beacon_meta[%d];
+
+#seekto 0x%04X;
+struct {
+  u8 dst_callsign[6];
+  u8 dst_callsign_ssid;
+  u8 src_callsign[6];
+  u8 src_callsign_ssid;
+  u8 path_and_body[%d];
+} aprs_beacon_pkt[%d];
+
+#seekto 0xf92a;
+struct {
+  char padded_string[60];
+} aprs_beacon_status_txt[5];
+
 #seekto 0xFECA;
 u8 checksum;
 """
@@ -117,7 +273,7 @@
 STEPS = list(chirp_common.TUNING_STEPS)
 STEPS.remove(30.0)
 STEPS.append(100.0)
-STEPS.insert(2, 0.0) # There is a skipped tuning step ad index 2 (?)
+STEPS.insert(2, 0.0) # There is a skipped tuning step at index 2 (?)
 SKIPS = ["", "S", "P"]
 
 CHARSET = ["%i" % int(x) for x in range(0, 10)] + \
@@ -285,9 +441,16 @@
     _memsize = 65227
     _block_lengths = [ 10, 65217 ]
     _block_size = 32
+    _mem_params = (0xC24A, # APRS beacon metadata address.
+                   40,     # Number of beacons stored.
+                   0xC60A, # APRS beacon content address.
+                   194,    # Length of beacon data stored.
+                   40)     # Number of beacons stored.
+    _has_vibrate = False
+    _has_af_dual = True
 
     def process_mmap(self):
-        self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+        self._memobj = bitwise.parse(MEM_FORMAT % self._mem_params, self._mmap)
 
     def get_features(self):
         rf = chirp_common.RadioFeatures()
@@ -317,6 +480,17 @@
                  yaesu_clone.YaesuChecksum(0x07CA, 0x0848),
                  yaesu_clone.YaesuChecksum(0x0000, 0xFEC9) ]
 
+    @staticmethod
+    def _add_ff_pad(val, length):
+        return val.ljust(length, "\xFF")[:length]
+
+    @classmethod
+    def _strip_ff_pads(cls, messages):
+        result = []
+        for msg_text in messages:
+            result.append(str(msg_text).rstrip("\xFF"))
+        return result
+
     def get_memory(self, number):
         flag = self._memobj.flag[number-1]
         _mem = self._memobj.memory[number-1]
@@ -341,10 +515,8 @@
         mem.power = POWER_LEVELS[3 - _mem.power]
         mem.skip = flag.pskip and "P" or flag.skip and "S" or ""
 
-        for i in str(_mem.label):
-            if i == "\xFF":
-                break
-            mem.name += CHARSET[ord(i)]
+        charset = ''.join(CHARSET).ljust(256, '.')
+        mem.name = str(_mem.label).rstrip("\xFF").translate(charset)
 
         return mem
 
@@ -392,7 +564,7 @@
             _mem.power = 0
 
         label = "".join([chr(CHARSET.index(x)) for x in mem.name.rstrip()])
-        _mem.label = label.ljust(16, "\xFF")
+        _mem.label = self._add_ff_pad(label, 16)
         # We only speak english here in chirpville
         _mem.charsetbits[0] = 0x00
         _mem.charsetbits[1] = 0x00
@@ -407,4 +579,685 @@
 class VX8DRadio(VX8Radio):
     """Yaesu VX-8DR"""
     _model = "AH29D"
+    _mem_params = (0xC24A, # APRS beacon metadata address.
+                   50,     # Number of beacons stored.
+                   0xC6FA, # APRS beacon content address.
+                   146,    # Length of beacon data stored.
+                   50)     # Number of beacons stored.
     VARIANT = "DR"
+
+    _SG_RE = re.compile(r"(?P<sign>[-+NESW]?)(?P<d>[\d]+)[\s\.,]*"
+                         "(?P<m>[\d]*)[\s\']*(?P<s>[\d]*)")
+
+    _RX_BAUD = ("off", "1200 baud", "9600 baud")
+    _TX_DELAY = ("100ms", "150ms", "200ms", "250ms", "300ms",
+                 "400ms", "500ms", "750ms", "1000ms")
+    _WIND_UNITS = ("m/s", "mph")
+    _RAIN_UNITS = ("mm", "inch")
+    _TEMP_UNITS = ("C", "F")
+    _ALT_UNITS = ("m", "ft")
+    _DIST_UNITS = ("km", "mile")
+    _POS_UNITS = ("dd.mmmm'", "dd mm'ss\"")
+    _SPEED_UNITS = ("km/h", "knot", "mph")
+    _TIME_SOURCE = ("manual", "GPS")
+    _TZ = ("-13:00", "-13:30", "-12:00", "-12:30", "-11:00", "-11:30",
+           "-10:00", "-10:30", "-09:00", "-09:30", "-08:00", "-08:30",
+           "-07:00", "-07:30", "-06:00", "-06:30", "-05:00", "-05:30",
+           "-04:00", "-04:30", "-03:00", "-03:30", "-02:00", "-02:30",
+           "-01:00", "-01:30", "-00:00", "-00:30", "+01:00", "+01:30",
+           "+02:00", "+02:30", "+03:00", "+03:30", "+04:00", "+04:30",
+           "+05:00", "+05:30", "+06:00", "+06:30", "+07:00", "+07:30",
+           "+08:00", "+08:30", "+09:00", "+09:30", "+10:00", "+10:30",
+           "+11:00", "+11:30")
+    _BEACON_TYPE = ("Off", "Interval", "SmartBeaconing")
+    _SMARTBEACON_PROFILE = ("Off", "Type 1", "Type 2", "Type 3")
+    _BEACON_INT = ("30s", "1m", "2m", "3m", "5m", "10m", "15m",
+                   "20m", "30m", "60m")
+    _DIGI_PATHS = ("OFF", "WIDE1-1", "WIDE1-1, WIDE2-1", "Digi Path 4",
+                   "Digi Path 5", "Digi Path 6", "Digi Path 7", "Digi Path 8")
+    _MSG_GROUP_NAMES = ("Message Group 1", "Message Group 2",
+                        "Message Group 3", "Message Group 4",
+                        "Message Group 5", "Message Group 6",
+                        "Message Group 7", "Message Group 8")
+    _POSITIONS = ("GPS", "Manual Latitude/Longitude",
+                  "Manual Latitude/Longitude", "P1", "P2", "P3", "P4",
+                  "P5", "P6", "P7", "P8", "P9")
+    _FLASH = ("OFF", "2 seconds", "4 seconds", "6 seconds", "8 seconds",
+              "10 seconds", "20 seconds", "30 seconds", "60 seconds",
+              "CONTINUOUS", "every 2 seconds", "every 3 seconds",
+              "every 4 seconds", "every 5 seconds", "every 6 seconds",
+              "every 7 seconds", "every 8 seconds", "every 9 seconds",
+              "every 10 seconds", "every 20 seconds", "every 30 seconds",
+              "every 40 seconds", "every 50 seconds", "every minute",
+              "every 2 minutes", "every 3 minutes", "every 4 minutes",
+              "every 5 minutes", "every 6 minutes", "every 7 minutes",
+              "every 8 minutes", "every 9 minutes", "every 10 minutes")
+    _MY_SYMBOL = ("/[ Person", "/b Bike", "/> Car", "User selected")
+
+    def get_features(self):
+        rf = VX8Radio.get_features(self)
+        rf.has_settings = True
+        return rf
+
+    @classmethod
+    def _digi_path_to_str(cls, path):
+        path_cmp = []
+        for entry in path.entry:
+            callsign = str(entry.callsign).rstrip("\xFF")
+            if not callsign:
+                break
+            path_cmp.append("%s-%d" % (callsign, entry.ssid))
+        return ",".join(path_cmp)
+
+    @staticmethod
+    def _latlong_sanity(sign, l_d, l_m, l_s, is_lat):
+        if sign not in (0, 1):
+            sign = 0
+        if is_lat:
+            d_max = 90
+        else:
+            d_max = 180
+        if l_d < 0 or l_d > d_max:
+            l_d = 0
+            l_m = 0
+            l_s = 0
+        if l_m < 0 or l_m > 60:
+            l_m = 0
+            l_s = 0
+        if l_s < 0 or l_s > 60:
+            l_s = 0
+        return sign, l_d, l_m, l_s
+
+    @classmethod
+    def _latlong_to_str(cls, sign, l_d, l_m, l_s, is_lat, to_sexigesimal=True):
+        sign, l_d, l_m, l_s = cls._latlong_sanity(sign, l_d, l_m, l_s, is_lat)
+        mult = sign and -1 or 1
+        if to_sexigesimal:
+            return "%d,%d'%d\"" % (mult * l_d, l_m, l_s)
+        return "%0.5f" % (mult * l_d + (l_m / 60.0) + (l_s / (60.0 * 60.0)))
+
+    @classmethod
+    def _str_to_latlong(cls, lat_long, is_lat):
+        sign = 0
+        result = [0, 0, 0]
+
+        lat_long = lat_long.strip()
+
+        if not lat_long:
+            return 1, 0, 0, 0
+
+        try:
+            # DD.MMMMM is the simple case, try that first.
+            val = float(lat_long)
+            if val < 0:
+                sign = 1
+            val = abs(val)
+            result[0] = int(val)
+            result[1] = int(val * 60) % 60
+            result[2] = int(val * 3600) % 60
+        except ValueError:
+            # Try DD MM'SS" if DD.MMMMM failed.
+            match = cls._SG_RE.match(lat_long.strip())
+            if match:
+                if match.group("sign") and (match.group("sign") in "SE-"):
+                    sign = 1
+                else:
+                    sign = 0
+                if match.group("d"):
+                    result[0] = int(match.group("d"))
+                if match.group("m"):
+                    result[1] = int(match.group("m"))
+                if match.group("s"):
+                    result[2] = int(match.group("s"))
+            elif len(lat_long) > 4:
+                raise Exception("Lat/Long should be DD MM'SS\" or DD.MMMMM")
+
+        return cls._latlong_sanity(sign, result[0], result[1], result[2],
+                                   is_lat)
+
+    def _get_aprs_general_settings(self):
+        menu = RadioSettingGroup("aprs_general", "APRS General")
+        aprs = self._memobj.aprs
+
+        val = RadioSettingValueString(0, 6,
+            str(aprs.my_callsign.callsign).rstrip("\xFF"))
+        rs = RadioSetting("aprs.my_callsign.callsign", "My Callsign", val)
+        rs.set_apply_callback(self.apply_callsign, aprs.my_callsign)
+        menu.append(rs)
+
+        val = RadioSettingValueList(
+            chirp_common.APRS_SSID,
+            chirp_common.APRS_SSID[aprs.my_callsign.ssid])
+        rs = RadioSetting("aprs.my_callsign.ssid", "My SSID", val)
+        menu.append(rs)
+
+        val = RadioSettingValueList(self._MY_SYMBOL,
+                                    self._MY_SYMBOL[aprs.selected_my_symbol])
+        rs = RadioSetting("aprs.selected_my_symbol", "My Symbol", val)
+        menu.append(rs)
+
+        symbols = list(chirp_common.APRS_SYMBOLS)
+        selected = aprs.custom_symbol
+        if aprs.custom_symbol >= len(chirp_common.APRS_SYMBOLS):
+          symbols.append("%d" % aprs.custom_symbol)
+          selected = len(symbols) - 1
+        val = RadioSettingValueList(symbols, symbols[selected])
+        rs = RadioSetting("aprs.custom_symbol_text", "User Selected Symbol",
+                          val)
+        rs.set_apply_callback(self.apply_custom_symbol, aprs)
+        menu.append(rs)
+
+        val = RadioSettingValueList(
+            chirp_common.APRS_POSITION_COMMENT,
+            chirp_common.APRS_POSITION_COMMENT[aprs.selected_position_comment])
+        rs = RadioSetting("aprs.selected_position_comment", "Position Comment",
+                          val)
+        menu.append(rs)
+
+        latitude = self._latlong_to_str(aprs.latitude_sign,
+                                        aprs.latitude_degree,
+                                        aprs.latitude_minute,
+                                        aprs.latitude_second,
+                                        True, aprs.aprs_units_position_mmss)
+        longitude = self._latlong_to_str(aprs.longitude_sign,
+                                         aprs.longitude_degree,
+                                         aprs.longitude_minute,
+                                         aprs.longitude_second,
+                                         False, aprs.aprs_units_position_mmss)
+
+        # TODO: Rebuild this when aprs_units_position_mmss changes.
+        # TODO: Rebuild this when latitude/longitude change.
+        # TODO: Add saved positions p1 - p10 to memory map.
+        position_str = list(self._POSITIONS)
+        #position_str[1] = "%s %s" % (latitude, longitude)
+        #position_str[2] = "%s %s" % (latitude, longitude)
+        val = RadioSettingValueList(position_str,
+                                    position_str[aprs.selected_position])
+        rs = RadioSetting("aprs.selected_position", "My Position", val)
+        menu.append(rs)
+
+        val = RadioSettingValueString(0, 10, latitude)
+        rs = RadioSetting("latitude", "Manual Latitude", val)
+        rs.set_apply_callback(self.apply_lat_long, aprs)
+        menu.append(rs)
+
+        val = RadioSettingValueString(0, 11, longitude)
+        rs = RadioSetting("longitude", "Manual Longitude", val)
+        rs.set_apply_callback(self.apply_lat_long, aprs)
+        menu.append(rs)
+
+        val = RadioSettingValueList(self._TIME_SOURCE,
+            self._TIME_SOURCE[aprs.set_time_manually])
+        rs = RadioSetting("aprs.set_time_manually", "Time Source", val)
+        menu.append(rs)
+
+        val = RadioSettingValueList(self._TZ, self._TZ[aprs.timezone])
+        rs = RadioSetting("aprs.timezone", "Timezone", val)
+        menu.append(rs)
+
+        val = RadioSettingValueList(self._SPEED_UNITS,
+                                    self._SPEED_UNITS[aprs.aprs_units_speed])
+        rs = RadioSetting("aprs.aprs_units_speed", "APRS Speed Units", val)
+        menu.append(rs)
+
+        val = RadioSettingValueList(self._SPEED_UNITS,
+                                    self._SPEED_UNITS[aprs.gps_units_speed])
+        rs = RadioSetting("aprs.gps_units_speed", "GPS Speed Units", val)
+        menu.append(rs)
+
+        val = RadioSettingValueList(self._ALT_UNITS,
+            self._ALT_UNITS[aprs.aprs_units_altitude_ft])
+        rs = RadioSetting("aprs.aprs_units_altitude_ft", "APRS Altitude Units",
+                          val)
+        menu.append(rs)
+
+        val = RadioSettingValueList(self._ALT_UNITS,
+            self._ALT_UNITS[aprs.gps_units_altitude_ft])
+        rs = RadioSetting("aprs.gps_units_altitude_ft", "GPS Altitude Units",
+                          val)
+        menu.append(rs)
+
+        val = RadioSettingValueList(self._POS_UNITS,
+            self._POS_UNITS[aprs.aprs_units_position_mmss])
+        rs = RadioSetting("aprs.aprs_units_position_mmss",
+                          "APRS Position Format", val)
+        menu.append(rs)
+
+        val = RadioSettingValueList(self._POS_UNITS,
+            self._POS_UNITS[aprs.gps_units_position_sss])
+        rs = RadioSetting("aprs.gps_units_position_sss",
+                          "GPS Position Format", val)
+        menu.append(rs)
+
+        val = RadioSettingValueList(self._DIST_UNITS,
+            self._DIST_UNITS[aprs.aprs_units_distance_m])
+        rs = RadioSetting("aprs.aprs_units_distance_m", "APRS Distance Units",
+                          val)
+        menu.append(rs)
+
+        val = RadioSettingValueList(self._WIND_UNITS,
+                                    self._WIND_UNITS[aprs.aprs_units_wind_mph])
+        rs = RadioSetting("aprs.aprs_units_wind_mph", "APRS Wind Speed Units",
+                          val)
+        menu.append(rs)
+
+        val = RadioSettingValueList(self._RAIN_UNITS,
+            self._RAIN_UNITS[aprs.aprs_units_rain_inch])
+        rs = RadioSetting("aprs.aprs_units_rain_inch", "APRS Rain Units", val)
+        menu.append(rs)
+
+        val = RadioSettingValueList(self._TEMP_UNITS,
+            self._TEMP_UNITS[aprs.aprs_units_temperature_f])
+        rs = RadioSetting("aprs.aprs_units_temperature_f",
+                          "APRS Temperature Units", val)
+        menu.append(rs)
+
+        return menu
+
+    def _get_aprs_rx_settings(self):
+        menu = RadioSettingGroup("aprs_rx", "APRS Receive")
+        aprs = self._memobj.aprs
+
+        val = RadioSettingValueList(self._RX_BAUD, self._RX_BAUD[aprs.rx_baud])
+        rs = RadioSetting("aprs.rx_baud", "Modem RX", val)
+        menu.append(rs)
+
+        val = RadioSettingValueBoolean(aprs.aprs_mute)
+        rs = RadioSetting("aprs.aprs_mute", "APRS Mute", val)
+        menu.append(rs)
+
+        if self._has_af_dual:
+            val = RadioSettingValueBoolean(aprs.af_dual)
+            rs = RadioSetting("aprs.af_dual", "AF Dual", val)
+            menu.append(rs)
+
+        val = RadioSettingValueBoolean(aprs.ring_msg)
+        rs = RadioSetting("aprs.ring_msg", "Ring on Message RX", val)
+        menu.append(rs)
+
+        val = RadioSettingValueBoolean(aprs.ring_beacon)
+        rs = RadioSetting("aprs.ring_beacon", "Ring on Beacon RX", val)
+        menu.append(rs)
+
+        val = RadioSettingValueList(self._FLASH,
+                                    self._FLASH[aprs.flash_msg])
+        rs = RadioSetting("aprs.flash_msg", "Flash on personal message", val)
+        menu.append(rs)
+
+        if self._has_vibrate:
+            val = RadioSettingValueList(self._FLASH,
+                                        self._FLASH[aprs.vibrate_msg])
+            rs = RadioSetting("aprs.vibrate_msg",
+                              "Vibrate on personal message", val)
+            menu.append(rs)
+
+        val = RadioSettingValueList(self._FLASH[:10],
+                                    self._FLASH[aprs.flash_bln])
+        rs = RadioSetting("aprs.flash_bln", "Flash on bulletin message", val)
+        menu.append(rs)
+
+        if self._has_vibrate:
+            val = RadioSettingValueList(self._FLASH[:10],
+                                        self._FLASH[aprs.vibrate_bln])
+            rs = RadioSetting("aprs.vibrate_bln",
+                              "Vibrate on bulletin message", val)
+            menu.append(rs)
+
+        val = RadioSettingValueList(self._FLASH[:10],
+                                    self._FLASH[aprs.flash_grp])
+        rs = RadioSetting("aprs.flash_grp", "Flash on group message", val)
+        menu.append(rs)
+
+        if self._has_vibrate:
+            val = RadioSettingValueList(self._FLASH[:10],
+                                        self._FLASH[aprs.vibrate_grp])
+            rs = RadioSetting("aprs.vibrate_grp",
+                              "Vibrate on group message", val)
+            menu.append(rs)
+
+        filter_val = [m.padded_string for m in aprs.msg_group]
+        filter_val = self._strip_ff_pads(filter_val)
+        for index, filter_text in enumerate(filter_val):
+            val = RadioSettingValueString(0, 9, filter_text)
+            rs = RadioSetting("aprs.msg_group_%d" % index,
+                              "Message Group %d" % (index + 1), val)
+            menu.append(rs)
+            rs.set_apply_callback(self.apply_ff_padded_string,
+                                  aprs.msg_group[index])
+        # TODO: Use filter_val as the list entries and update it on edit.
+        val = RadioSettingValueList(
+            self._MSG_GROUP_NAMES,
+            self._MSG_GROUP_NAMES[aprs.selected_msg_group])
+        rs = RadioSetting("aprs.selected_msg_group", "Selected Message Group",
+                          val)
+        menu.append(rs)
+
+        val = RadioSettingValueBoolean(aprs.filter_mic_e)
+        rs = RadioSetting("aprs.filter_mic_e", "Receive Mic-E Beacons", val)
+        menu.append(rs)
+
+        val = RadioSettingValueBoolean(aprs.filter_position)
+        rs = RadioSetting("aprs.filter_position", "Receive Position Beacons",
+                          val)
+        menu.append(rs)
+
+        val = RadioSettingValueBoolean(aprs.filter_weather)
+        rs = RadioSetting("aprs.filter_weather", "Receive Weather Beacons",
+                          val)
+        menu.append(rs)
+
+        val = RadioSettingValueBoolean(aprs.filter_object)
+        rs = RadioSetting("aprs.filter_object", "Receive Object Beacons", val)
+        menu.append(rs)
+
+        val = RadioSettingValueBoolean(aprs.filter_item)
+        rs = RadioSetting("aprs.filter_item", "Receive Item Beacons", val)
+        menu.append(rs)
+
+        val = RadioSettingValueBoolean(aprs.filter_status)
+        rs = RadioSetting("aprs.filter_status", "Receive Status Beacons", val)
+        menu.append(rs)
+
+        val = RadioSettingValueBoolean(aprs.filter_other)
+        rs = RadioSetting("aprs.filter_other", "Receive Other Beacons", val)
+        menu.append(rs)
+
+        return menu
+
+    def _get_aprs_tx_settings(self):
+        menu = RadioSettingGroup("aprs_tx", "APRS Transmit")
+        aprs = self._memobj.aprs
+
+        beacon_type = (aprs.tx_smartbeacon << 1) | aprs.tx_interval_beacon;
+        val = RadioSettingValueList(self._BEACON_TYPE,
+                                    self._BEACON_TYPE[beacon_type])
+        rs = RadioSetting("aprs.transmit", "TX Beacons", val)
+        rs.set_apply_callback(self.apply_beacon_type, aprs)
+        menu.append(rs)
+
+        val = RadioSettingValueList(self._TX_DELAY,
+                                    self._TX_DELAY[aprs.tx_delay])
+        rs = RadioSetting("aprs.tx_delay", "TX Delay", val)
+        menu.append(rs)
+
+        val = RadioSettingValueList(self._BEACON_INT,
+                                    self._BEACON_INT[aprs.beacon_interval])
+        rs = RadioSetting("aprs.beacon_interval", "Beacon Interval", val)
+        menu.append(rs)
+
+        desc = []
+        status = [m.padded_string for m in self._memobj.aprs_beacon_status_txt]
+        status = self._strip_ff_pads(status)
+        for index, msg_text in enumerate(status):
+            val = RadioSettingValueString(0, 60, msg_text)
+            desc.append("Beacon Status Text %d" % (index + 1))
+            rs = RadioSetting("aprs_beacon_status_txt_%d" % index, desc[-1],
+                              val)
+            rs.set_apply_callback(self.apply_ff_padded_string,
+                                  self._memobj.aprs_beacon_status_txt[index])
+            menu.append(rs)
+        val = RadioSettingValueList(desc,
+                                    desc[aprs.selected_beacon_status_txt])
+        rs = RadioSetting("aprs.selected_beacon_status_txt",
+                          "Beacon Status Text", val)
+        menu.append(rs)
+
+        message_macro = [m.padded_string for m in aprs.message_macro]
+        message_macro = self._strip_ff_pads(message_macro)
+        for index, msg_text in enumerate(message_macro):
+            val = RadioSettingValueString(0, 16, msg_text)
+            rs = RadioSetting("aprs.message_macro_%d" % index,
+                              "Message Macro %d" % (index + 1), val)
+            rs.set_apply_callback(self.apply_ff_padded_string,
+                                  aprs.message_macro[index])
+            menu.append(rs)
+
+        path_str = list(self._DIGI_PATHS)
+        path_str[3] = self._digi_path_to_str(aprs.digi_path_3_6[0])
+        val = RadioSettingValueString(0, 22, path_str[3])
+        rs = RadioSetting("aprs.digi_path_3", "Digi Path 4 (2 entries)", val)
+        rs.set_apply_callback(self.apply_digi_path, aprs.digi_path_3_6[0])
+        menu.append(rs)
+
+        path_str[4] = self._digi_path_to_str(aprs.digi_path_3_6[1])
+        val = RadioSettingValueString(0, 22, path_str[4])
+        rs = RadioSetting("aprs.digi_path_4", "Digi Path 5 (2 entries)", val)
+        rs.set_apply_callback(self.apply_digi_path, aprs.digi_path_3_6[1])
+        menu.append(rs)
+
+        path_str[5] = self._digi_path_to_str(aprs.digi_path_3_6[2])
+        val = RadioSettingValueString(0, 22, path_str[5])
+        rs = RadioSetting("aprs.digi_path_5", "Digi Path 6 (2 entries)", val)
+        rs.set_apply_callback(self.apply_digi_path, aprs.digi_path_3_6[2])
+        menu.append(rs)
+
+        path_str[6] = self._digi_path_to_str(aprs.digi_path_3_6[3])
+        val = RadioSettingValueString(0, 22, path_str[6])
+        rs = RadioSetting("aprs.digi_path_6", "Digi Path 7 (2 entries)", val)
+        rs.set_apply_callback(self.apply_digi_path, aprs.digi_path_3_6[3])
+        menu.append(rs)
+
+        path_str[7] = self._digi_path_to_str(aprs.digi_path_7)
+        val = RadioSettingValueString(0, 88, path_str[7])
+        rs = RadioSetting("aprs.digi_path_7", "Digi Path 8 (8 entries)", val)
+        rs.set_apply_callback(self.apply_digi_path, aprs.digi_path_7)
+        menu.append(rs)
+
+        # Show friendly messages for empty slots rather than blanks.
+        # TODO: Rebuild this when digi_path_[34567] change.
+        #path_str[3] = path_str[3] or self._DIGI_PATHS[3]
+        #path_str[4] = path_str[4] or self._DIGI_PATHS[4]
+        #path_str[5] = path_str[5] or self._DIGI_PATHS[5]
+        #path_str[6] = path_str[6] or self._DIGI_PATHS[6]
+        #path_str[7] = path_str[7] or self._DIGI_PATHS[7]
+        path_str[3] = self._DIGI_PATHS[3]
+        path_str[4] = self._DIGI_PATHS[4]
+        path_str[5] = self._DIGI_PATHS[5]
+        path_str[6] = self._DIGI_PATHS[6]
+        path_str[7] = self._DIGI_PATHS[7]
+        val = RadioSettingValueList(path_str,
+                                    path_str[aprs.selected_digi_path])
+        rs = RadioSetting("aprs.selected_digi_path", "Selected Digi Path", val)
+        menu.append(rs)
+
+        return menu
+
+    def _get_aprs_smartbeacon(self):
+        menu = RadioSettingGroup("aprs_smartbeacon", "APRS SmartBeacon")
+        aprs = self._memobj.aprs
+
+        val = RadioSettingValueList(
+            self._SMARTBEACON_PROFILE,
+            self._SMARTBEACON_PROFILE[aprs.active_smartbeaconing])
+        rs = RadioSetting("aprs.active_smartbeaconing", "SmartBeacon profile",
+                          val)
+        menu.append(rs)
+
+        for profile in range(3):
+            pfx = "type%d" % (profile + 1)
+            path = "aprs.smartbeaconing_profile[%d]" % profile
+            prof = aprs.smartbeaconing_profile[profile]
+
+            low_val = RadioSettingValueInteger(2, 30, prof.low_speed_mph)
+            high_val = RadioSettingValueInteger(3, 70, prof.high_speed_mph)
+            low_val.get_max = lambda: min(30, int(high_val.get_value()) - 1)
+
+            rs = RadioSetting("%s.low_speed_mph" % path,
+                              "%s Low Speed (mph)" % pfx, low_val)
+            menu.append(rs)
+
+            rs = RadioSetting("%s.high_speed_mph" % path,
+                              "%s High Speed (mph)" % pfx, high_val)
+            menu.append(rs)
+
+            val = RadioSettingValueInteger(1, 100, prof.slow_rate_min)
+            rs = RadioSetting("%s.slow_rate_min" % path,
+                              "%s Slow rate (minutes)" % pfx, val)
+            menu.append(rs)
+
+            val = RadioSettingValueInteger(10, 180, prof.fast_rate_sec)
+            rs = RadioSetting("%s.fast_rate_sec" % path,
+                              "%s Fast rate (seconds)" % pfx, val)
+            menu.append(rs)
+
+            val = RadioSettingValueInteger(5, 90, prof.turn_angle)
+            rs = RadioSetting("%s.turn_angle" % path,
+                              "%s Turn angle (degrees)" % pfx, val)
+            menu.append(rs)
+
+            val = RadioSettingValueInteger(1, 255, prof.turn_slop)
+            rs = RadioSetting("%s.turn_slop" % path,
+                              "%s Turn slop" % pfx, val)
+            menu.append(rs)
+
+            val = RadioSettingValueInteger(5, 180, prof.turn_time_sec)
+            rs = RadioSetting("%s.turn_time_sec" % path,
+                              "%s Turn time (seconds)" % pfx, val)
+            menu.append(rs)
+
+        return menu
+ 
+    def _get_settings(self):
+        top = RadioSettingGroup("all", "All Settings",
+                                self._get_aprs_general_settings(),
+                                self._get_aprs_rx_settings(),
+                                self._get_aprs_tx_settings(),
+                                self._get_aprs_smartbeacon())
+        return top
+
+    def get_settings(self):
+        try:
+            return self._get_settings()
+        except:
+            import traceback
+            print "Failed to parse settings:"
+            traceback.print_exc()
+            return None
+
+    @staticmethod
+    def apply_custom_symbol(setting, obj):
+        # Ensure new value falls within known bounds, otherwise leave it as
+        # it's a custom value from the radio that's outside our list.
+        if setting.value.get_value() in chirp_common.APRS_SYMBOLS:
+            setattr(obj, "custom_symbol",
+                    chirp_common.APRS_SYMBOLS.index(setting.value.get_value()))
+
+    @classmethod
+    def _apply_callsign(cls, callsign, obj, default_ssid=None):
+        ssid = default_ssid
+        dash_index = callsign.find("-")
+        if dash_index >= 0:
+            ssid = callsign[dash_index + 1:]
+            callsign = callsign[:dash_index]
+            try:
+                ssid = int(ssid) % 16
+            except ValueError:
+                ssid = default_ssid
+        setattr(obj, "callsign", cls._add_ff_pad(callsign, 6))
+        if ssid is not None:
+            setattr(obj, "ssid", ssid)
+
+    def apply_beacon_type(cls, setting, obj):
+        beacon_type = str(setting.value.get_value())
+        beacon_index = cls._BEACON_TYPE.index(beacon_type)
+        tx_smartbeacon = beacon_index >> 1
+        tx_interval_beacon = beacon_index & 1
+        if tx_interval_beacon:
+            setattr(obj, "tx_interval_beacon", 1)
+            setattr(obj, "tx_smartbeacon", 0)
+        elif tx_smartbeacon:
+            setattr(obj, "tx_interval_beacon", 0)
+            setattr(obj, "tx_smartbeacon", 1)
+        else:
+            setattr(obj, "tx_interval_beacon", 0)
+            setattr(obj, "tx_smartbeacon", 0)
+
+    @classmethod
+    def apply_callsign(cls, setting, obj, default_ssid=None):
+        # Uppercase, strip SSID then FF pad to max string length.
+        callsign = setting.value.get_value().upper()
+        cls._apply_callsign(callsign, obj, default_ssid)
+
+    def apply_digi_path(self, setting, obj):
+        # Parse and map to aprs.digi_path_4_7[0-3] or aprs.digi_path_8
+        # and FF terminate.
+        path = str(setting.value.get_value())
+        callsigns = [c.strip() for c in path.split(",")]
+        for index in range(len(obj.entry)):
+            try:
+                self._apply_callsign(callsigns[index], obj.entry[index], 0)
+            except IndexError:
+                self._apply_callsign("", obj.entry[index], 0)
+        if len(callsigns) > len(obj.entry):
+            raise Exception("This path only supports %d entries" % (index + 1))
+
+    @classmethod
+    def apply_ff_padded_string(cls, setting, obj):
+        # FF pad.
+        val = setting.value.get_value()
+        max_len = getattr(obj, "padded_string").size() / 8
+        val = str(val).rstrip()
+        setattr(obj, "padded_string", cls._add_ff_pad(val, max_len))
+
+    @classmethod
+    def apply_lat_long(cls, setting, obj):
+        name = setting.get_name()
+        is_latitude = name.endswith("latitude")
+        lat_long = setting.value.get_value().strip()
+        sign, l_d, l_m, l_s = cls._str_to_latlong(lat_long, is_latitude)
+        if os.getenv("CHIRP_DEBUG"):
+            print "%s: %d %d %d %d" % (name, sign, l_d, l_m, l_s)
+        setattr(obj, "%s_sign" % name, sign)
+        setattr(obj, "%s_degree" % name, l_d)
+        setattr(obj, "%s_minute" % name, l_m)
+        setattr(obj, "%s_second" % name, l_s)
+
+    def set_settings(self, settings):
+        _mem = self._memobj
+        for element in settings:
+            if not isinstance(element, RadioSetting):
+                self.set_settings(element)
+                continue
+            if not element.changed():
+                continue
+            try:
+                if element.has_apply_callback():
+                    print "Using apply callback"
+                    try:
+                        element.run_apply_callback()
+                    except NotImplementedError as e:
+                        print e
+                    continue
+
+                # Find the object containing setting.
+                obj = _mem
+                bits = element.get_name().split(".")
+                setting = bits[-1]
+                for name in bits[:-1]:
+                    if name.endswith("]"):
+                        name, index = name.split("[")
+                        index = int(index[:-1])
+                        obj = getattr(obj, name)[index]
+                    else:
+                        obj = getattr(obj, name)
+
+                try:
+                    old_val = getattr(obj, setting)
+                    if os.getenv("CHIRP_DEBUG"):
+                        print "Setting %s(%r) <= %s" % (
+                            element.get_name(), old_val, element.value)
+                    setattr(obj, setting, element.value)
+                except AttributeError as e:
+                    print "Setting %s is not in the memory map: %s" % (
+                        element.get_name(), e)
+            except Exception, e:
+                print element.get_name()
+                raise
+
+@directory.register
+class VX8GERadio(VX8DRadio):
+    """Yaesu VX-8GE"""
+    _model = "AH041"
+    VARIANT = "GE"
+    _has_vibrate = True
+    _has_af_dual = False

