Skip to content

Commit

Permalink
Add airframe .post scripts on NuttX targets
Browse files Browse the repository at this point in the history
  • Loading branch information
jlecoeur authored and bkueng committed Jul 22, 2019
1 parent e964af9 commit daeba4e
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 13 deletions.
1 change: 1 addition & 0 deletions ROMFS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ add_custom_command(
${romfs_gen_root_dir}/init.d/rcS
${romfs_gen_root_dir}/init.d/rc.serial
${romfs_gen_root_dir}/init.d/rc.autostart
${romfs_gen_root_dir}/init.d/rc.autostart.post
romfs_copy.stamp
COMMAND ${CMAKE_COMMAND} -E remove_directory ${romfs_gen_root_dir}
# TODO: we should only copy the files in ${romfs_copy_files}
Expand Down
7 changes: 7 additions & 0 deletions ROMFS/px4fmu_common/init.d/rcS
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,13 @@ else
#
sh /etc/init.d/rc.logging

#
# Set additional parameters and env variables for selected AUTOSTART.
#
if ! param compare SYS_AUTOSTART 0
then
sh /etc/init.d/rc.autostart.post
fi

if ! param compare SYS_PARAM_VER ${PARAM_DEFAULTS_VER}
then
Expand Down
18 changes: 15 additions & 3 deletions Tools/px4airframes/rcout.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os

class RCOutput():
def __init__(self, groups, board):
def __init__(self, groups, board, post_start=False):

result = ( "#\n"
"#\n"
Expand Down Expand Up @@ -41,7 +41,19 @@ def __init__(self, groups, board):
excluded = True
if excluded:
continue
path = os.path.split(param.GetPath())[1]

if post_start:
# Path to post-start sript
path = param.GetPostPath()
else:
# Path to start script
path = param.GetPath()

if not path:
continue

path = os.path.split(path)[1]

id_val = param.GetId()
name = param.GetFieldValue("short_desc")
long_desc = param.GetFieldValue("long_desc")
Expand All @@ -58,7 +70,7 @@ def __init__(self, groups, board):
result += "\n"

result += "\n"
self.output = result;
self.output = result

def Save(self, filename):
with codecs.open(filename, 'w', 'utf-8') as f:
Expand Down
26 changes: 16 additions & 10 deletions Tools/px4airframes/srcparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def GetClass(self):
Get parameter group vehicle type.
"""
return self.af_class

def GetImageName(self):
"""
Get parameter group image base name (w/o extension)
Expand Down Expand Up @@ -127,11 +127,12 @@ class Parameter(object):
# all others == 0 (sorted alphabetically)
}

def __init__(self, path, name, airframe_type, airframe_class, airframe_id, maintainer):
def __init__(self, path, post_path, name, airframe_type, airframe_class, airframe_id, maintainer):
self.fields = {}
self.outputs = {}
self.archs = {}
self.path = path
self.post_path = post_path
self.name = name
self.type = airframe_type
self.af_class = airframe_class
Expand All @@ -141,6 +142,9 @@ def __init__(self, path, name, airframe_type, airframe_class, airframe_id, maint
def GetPath(self):
return self.path

def GetPostPath(self):
return self.post_path

def GetName(self):
return self.name

Expand Down Expand Up @@ -384,8 +388,14 @@ def Parse(self, path, contents):
sys.stderr.write("Aborting due to missing @name tag in file: '%s'\n" % path)
return False

# Check if a .post script exists
if os.path.isfile(path + '.post'):
post_path = path + '.post'
else:
post_path = None

# We already know this is an airframe config, so add it
param = Parameter(path, airframe_name, airframe_type, airframe_class, airframe_id, maintainer)
param = Parameter(path, post_path, airframe_name, airframe_type, airframe_class, airframe_id, maintainer)

# Done with file, store
for tag in tags:
Expand All @@ -407,13 +417,10 @@ def Parse(self, path, contents):
# Store outputs
for arch in archs:
param.SetArch(arch, archs[arch])




# Store the parameter
#Create a class-specific airframe group. This is needed to catch cases where an airframe type might cross classes (e.g. simulation)

# Create a class-specific airframe group. This is needed to catch cases where an airframe type might cross classes (e.g. simulation)
class_group_identifier=airframe_type+airframe_class
if class_group_identifier not in self.param_groups:
#self.param_groups[airframe_type] = ParameterGroup(airframe_type) #HW TEST REMOVE
Expand Down Expand Up @@ -458,7 +465,7 @@ def GetParamGroups(self):
groups = sorted(groups, key=lambda x: x.GetName())
groups = sorted(groups, key=lambda x: x.GetClass())
groups = sorted(groups, key=lambda x: self.priority.get(x.GetName(), 0), reverse=True)

#Rename duplicate groups to include the class (creating unique headings in page TOC)
duplicate_test=set()
duplicate_set=set()
Expand All @@ -471,5 +478,4 @@ def GetParamGroups(self):
if group.GetName() in duplicate_set:
group.name=group.GetName()+' (%s)' % group.GetClass()


return groups
8 changes: 8 additions & 0 deletions Tools/px_process_airframes.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,19 @@ def main():
out = markdownout.MarkdownTablesOutput(param_groups, args.board, args.image_path)
out.Save(args.markdown)

# Output to start scripts
if args.start_script:
# Airframe start script
if args.verbose: print("Creating start script " + args.start_script)
out = rcout.RCOutput(param_groups, args.board)
out.Save(args.start_script)

# Airframe post-start script
post_start_script = args.start_script + '.post'
if args.verbose: print("Creating post-start script " + post_start_script)
out_post = rcout.RCOutput(param_groups, args.board, post_start=True)
out_post.Save(post_start_script)

if (args.verbose): print("All done!")


Expand Down

0 comments on commit daeba4e

Please sign in to comment.