mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 02:16:53 +08:00
Add airframe .post scripts on NuttX targets
This commit is contained in:
committed by
Beat Küng
parent
e964af9262
commit
daeba4e75f
@@ -83,6 +83,7 @@ add_custom_command(
|
|||||||
${romfs_gen_root_dir}/init.d/rcS
|
${romfs_gen_root_dir}/init.d/rcS
|
||||||
${romfs_gen_root_dir}/init.d/rc.serial
|
${romfs_gen_root_dir}/init.d/rc.serial
|
||||||
${romfs_gen_root_dir}/init.d/rc.autostart
|
${romfs_gen_root_dir}/init.d/rc.autostart
|
||||||
|
${romfs_gen_root_dir}/init.d/rc.autostart.post
|
||||||
romfs_copy.stamp
|
romfs_copy.stamp
|
||||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${romfs_gen_root_dir}
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${romfs_gen_root_dir}
|
||||||
# TODO: we should only copy the files in ${romfs_copy_files}
|
# TODO: we should only copy the files in ${romfs_copy_files}
|
||||||
|
|||||||
@@ -490,6 +490,13 @@ else
|
|||||||
#
|
#
|
||||||
sh /etc/init.d/rc.logging
|
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}
|
if ! param compare SYS_PARAM_VER ${PARAM_DEFAULTS_VER}
|
||||||
then
|
then
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import codecs
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
class RCOutput():
|
class RCOutput():
|
||||||
def __init__(self, groups, board):
|
def __init__(self, groups, board, post_start=False):
|
||||||
|
|
||||||
result = ( "#\n"
|
result = ( "#\n"
|
||||||
"#\n"
|
"#\n"
|
||||||
@@ -41,7 +41,19 @@ class RCOutput():
|
|||||||
excluded = True
|
excluded = True
|
||||||
if excluded:
|
if excluded:
|
||||||
continue
|
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()
|
id_val = param.GetId()
|
||||||
name = param.GetFieldValue("short_desc")
|
name = param.GetFieldValue("short_desc")
|
||||||
long_desc = param.GetFieldValue("long_desc")
|
long_desc = param.GetFieldValue("long_desc")
|
||||||
@@ -58,7 +70,7 @@ class RCOutput():
|
|||||||
result += "\n"
|
result += "\n"
|
||||||
|
|
||||||
result += "\n"
|
result += "\n"
|
||||||
self.output = result;
|
self.output = result
|
||||||
|
|
||||||
def Save(self, filename):
|
def Save(self, filename):
|
||||||
with codecs.open(filename, 'w', 'utf-8') as f:
|
with codecs.open(filename, 'w', 'utf-8') as f:
|
||||||
|
|||||||
@@ -127,11 +127,12 @@ class Parameter(object):
|
|||||||
# all others == 0 (sorted alphabetically)
|
# 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.fields = {}
|
||||||
self.outputs = {}
|
self.outputs = {}
|
||||||
self.archs = {}
|
self.archs = {}
|
||||||
self.path = path
|
self.path = path
|
||||||
|
self.post_path = post_path
|
||||||
self.name = name
|
self.name = name
|
||||||
self.type = airframe_type
|
self.type = airframe_type
|
||||||
self.af_class = airframe_class
|
self.af_class = airframe_class
|
||||||
@@ -141,6 +142,9 @@ class Parameter(object):
|
|||||||
def GetPath(self):
|
def GetPath(self):
|
||||||
return self.path
|
return self.path
|
||||||
|
|
||||||
|
def GetPostPath(self):
|
||||||
|
return self.post_path
|
||||||
|
|
||||||
def GetName(self):
|
def GetName(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
@@ -384,8 +388,14 @@ class SourceParser(object):
|
|||||||
sys.stderr.write("Aborting due to missing @name tag in file: '%s'\n" % path)
|
sys.stderr.write("Aborting due to missing @name tag in file: '%s'\n" % path)
|
||||||
return False
|
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
|
# 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
|
# Done with file, store
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
@@ -408,12 +418,9 @@ class SourceParser(object):
|
|||||||
for arch in archs:
|
for arch in archs:
|
||||||
param.SetArch(arch, archs[arch])
|
param.SetArch(arch, archs[arch])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Store the parameter
|
# 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
|
class_group_identifier=airframe_type+airframe_class
|
||||||
if class_group_identifier not in self.param_groups:
|
if class_group_identifier not in self.param_groups:
|
||||||
#self.param_groups[airframe_type] = ParameterGroup(airframe_type) #HW TEST REMOVE
|
#self.param_groups[airframe_type] = ParameterGroup(airframe_type) #HW TEST REMOVE
|
||||||
@@ -471,5 +478,4 @@ class SourceParser(object):
|
|||||||
if group.GetName() in duplicate_set:
|
if group.GetName() in duplicate_set:
|
||||||
group.name=group.GetName()+' (%s)' % group.GetClass()
|
group.name=group.GetName()+' (%s)' % group.GetClass()
|
||||||
|
|
||||||
|
|
||||||
return groups
|
return groups
|
||||||
|
|||||||
@@ -118,11 +118,19 @@ def main():
|
|||||||
out = markdownout.MarkdownTablesOutput(param_groups, args.board, args.image_path)
|
out = markdownout.MarkdownTablesOutput(param_groups, args.board, args.image_path)
|
||||||
out.Save(args.markdown)
|
out.Save(args.markdown)
|
||||||
|
|
||||||
|
# Output to start scripts
|
||||||
if args.start_script:
|
if args.start_script:
|
||||||
|
# Airframe start script
|
||||||
if args.verbose: print("Creating start script " + args.start_script)
|
if args.verbose: print("Creating start script " + args.start_script)
|
||||||
out = rcout.RCOutput(param_groups, args.board)
|
out = rcout.RCOutput(param_groups, args.board)
|
||||||
out.Save(args.start_script)
|
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!")
|
if (args.verbose): print("All done!")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user