Skip to content

Commit

Permalink
Use .pymavlink folder and no need for resets
Browse files Browse the repository at this point in the history
  • Loading branch information
shancock884 committed Mar 20, 2024
1 parent 6508d8d commit 55b4553
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions DFReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,16 +567,15 @@ def reset(self):
self.data = None
self.metadata_load_attempted = False

# Copy of function in mp_util, to avoid dependency on MavProxy
def dot_mavproxy(self, name=None):
def dot_pymavlink(self, *args):
'''return a path to store mavproxy data'''
if 'HOME' not in os.environ:
dir = os.path.join(os.environ['LOCALAPPDATA'], '.mavproxy')
dir = os.path.join(os.environ['LOCALAPPDATA'], '.pymavlink')
else:
dir = os.path.join(os.environ['HOME'], '.mavproxy')
if name is None:
dir = os.path.join(os.environ['HOME'], '.pymavlink')
if len(args) == 0:
return dir
return os.path.join(dir, name)
return os.path.join(dir, *args)

def metadata_tree(self, verbose=False):
''' return a map between a log message and its metadata. May return
Expand All @@ -597,7 +596,7 @@ def metadata_tree(self, verbose=False):
}
if self.parent.mav_type not in mapping:
return None
path = self.dot_mavproxy(os.path.join("LogMessages", "%s.xml" % mapping[self.parent.mav_type]))
path = self.dot_pymavlink("LogMessages", "%s.xml" % mapping[self.parent.mav_type])
# Does the file exist?
if not os.path.exists(path):
if verbose:
Expand Down Expand Up @@ -833,8 +832,6 @@ def _add_msg(self, m):
self.mav_type = mavutil.mavlink.MAV_TYPE_SUBMARINE
elif m.Message.find("Blimp") != -1:
self.mav_type = mavutil.mavlink.MAV_TYPE_AIRSHIP
# Reset the meta data, when mav type is updated
self.metadata.reset()
if type == 'VER' and hasattr(m,'BU'):
build_types = { 1: mavutil.mavlink.MAV_TYPE_GROUND_ROVER,
2: mavutil.mavlink.MAV_TYPE_QUADROTOR,
Expand All @@ -847,8 +844,6 @@ def _add_msg(self, m):
mavtype = build_types.get(m.BU,None)
if mavtype is not None:
self.mav_type = mavtype
# Reset the meta data, when mav type is updated
self.metadata.reset()

if type == 'MODE':
if hasattr(m,'Mode') and isinstance(m.Mode, str):
Expand Down

0 comments on commit 55b4553

Please sign in to comment.