Index: src/mlx/xplane.py
===================================================================
--- src/mlx/xplane.py	(revision 429)
+++ src/mlx/xplane.py	(revision 431)
@@ -12,5 +12,5 @@
 import math
 
-from xplra import XPlane, MultiGetter, MultiSetter
+from xplra import XPlane, MultiGetter, MultiSetter, ProtocolException
 from xplra import TYPE_INT, TYPE_FLOAT, TYPE_DOUBLE
 from xplra import TYPE_FLOAT_ARRAY, TYPE_INT_ARRAY, TYPE_BYTE_ARRAY
@@ -97,10 +97,15 @@
             self._result = True
             return True
-        elif Handler._performRead(self._multiBuffer,
-                                  self._extra, self._validator):
-            self._result = self._multiBuffer
+
+        try:
+            if Handler._performRead(self._multiBuffer,
+                                    self._extra, self._validator):
+                self._result = self._multiBuffer
+                return True
+            else:
+                return False
+        except ProtocolException, e:
+            self._result = None
             return True
-        else:
-            return False
 
 class ShowMessageRequest(Request):
@@ -304,5 +309,10 @@
         attemptsLeft = Handler.NUM_READATTEMPTS
         while attemptsLeft>0:
-            multiGetter.execute()
+            try:
+                multiGetter.execute()
+            except ProtocolException, e:
+                print "xplane.Handler._performRead: " + str(e)
+                raise
+
             if validator is None or \
                Handler._callSafe(lambda: validator(multiGetter, extra)):
@@ -718,4 +728,11 @@
         self._fuelCallback = None
 
+        self._hasXFMC = None
+
+    @property
+    def hasXFMC(self):
+        """Indicate if the simulator has the X-FMC plugin."""
+        return self._hasXFMC
+
     def connect(self, aircraft):
         """Initiate a connection to the simulator."""
@@ -892,4 +909,8 @@
         simulator of the given type."""
         self._fsType = fsType
+
+        self._handler.requestRead([("xfmc/Status", TYPE_INT)],
+                                  self._xfmcStatusRead)
+
         with self._hotkeyLock:
             if self._hotkeyCodes is not None:
@@ -911,4 +932,5 @@
     def disconnected(self):
         """Called when a connection to the flight simulator has been broken."""
+        self._hasXFMC = None
         with self._hotkeyLock:
             self._clearHotkeyRequest()
@@ -929,4 +951,10 @@
         self._normalRequestID = None
         self._monitoring = False
+
+    def _xfmcStatusRead(self, data, extra):
+        """Called when the xfmc/Status dataref is read or not."""
+        self._hasXFMC = data is not None
+        print "xplane.Simulator: XFMC is %savailable" % \
+          ("" if self._hasXFMC else "not ")
 
     def _handleNormal(self, data, extra):
@@ -1008,4 +1036,5 @@
         will be replaced by a new one."""
         self._aircraftModel = model
+        model.simulator = self
 
         if self._monitoring:
@@ -1302,4 +1331,5 @@
         flapsNotches is a list of degrees of flaps that are available on the aircraft."""
         self._flapsNotches = flapsNotches
+        self._simulator = None
 
     @property
@@ -1307,4 +1337,14 @@
         """Get the name for this aircraft model."""
         return "X-Plane/Generic"
+
+    @property
+    def simulator(self):
+        """Get the simulator this aircraft model works for."""
+        return self._simulator
+
+    @simulator.setter
+    def simulator(self, simulator):
+        """Get the simulator this aircraft model works for."""
+        self._simulator = simulator
 
     def doesHandle(self, aircraft, aircraftInfo):
@@ -1340,8 +1380,15 @@
         self._addDataWithIndexMembers(data, "_monidx_",
                                       AircraftModel.monitoringData)
+        if self.simulator.hasXFMC:
+            print "xplane.AircraftModel.addMonitoringData: adding XFMC status dataref"""
+            self._addDatarefWithIndexMember(data, "xfmc/Status", TYPE_INT,
+                                            attrName = "_monidx_xfmcStatus")
 
     def getAircraftState(self, aircraft, timestamp, data):
         """Get an aircraft state object for the given monitoring data."""
         state = fs.AircraftState()
+
+        xfmcLNAVOn = self.simulator.hasXFMC and \
+                     (data[self._monidx_xfmcStatus]&0x03==0x03)
 
         state.timestamp = timestamp
@@ -1412,5 +1459,5 @@
         state.nav2 = self._convertFrequency(data[self._monidx_nav2])
         state.nav2_obs = self._convertOBS(data[self._monidx_nav2_obs])
-        state.nav2_manual = True
+        state.nav2_manual = not xfmcLNAVOn
         state.adf1 = str(data[self._monidx_adf1])
         state.adf2 = str(data[self._monidx_adf2])
@@ -1431,6 +1478,11 @@
         state.apMaster = data[self._monidx_apMaster]==2
         apState = data[self._monidx_apState]
-        state.apHeadingHold = (apState&0x00002)!=0
-        state.apHeading = data[self._monidx_apHeading]
+        if xfmcLNAVOn:
+           state.apHeadingHold = None
+           state.apHeading = None
+        else:
+            state.apHeadingHold = (apState&0x00002)!=0
+            state.apHeading = data[self._monidx_apHeading]
+
         state.apAltitudeHold = (apState&0x04000)!=0
         state.apAltitude = data[self._monidx_apAltitude]
@@ -1692,6 +1744,7 @@
         name."""
         return aircraft.type==const.AIRCRAFT_DH8D and \
-            description.find("Dash 8 Q400")!=-1 and \
-            liveryPath.startswith("Aircraft/Heavy Metal/Dash 8 Q400")
+          description.find("Dash 8 Q400")!=-1 and \
+          ((author=="2012" and tailnum=="N62890") or \
+           author.find("Jack Skieczius")!=-1)
 
     @property
