aboutsummaryrefslogtreecommitdiff
path: root/Tools
diff options
context:
space:
mode:
Diffstat (limited to 'Tools')
-rw-r--r--Tools/px4params/.gitignore2
-rw-r--r--Tools/px4params/README.md9
-rw-r--r--Tools/px4params/dokuwikiout.py27
-rw-r--r--Tools/px4params/output.py5
-rw-r--r--Tools/px4params/parser.py220
-rwxr-xr-xTools/px4params/px_process_params.py61
-rw-r--r--Tools/px4params/scanner.py34
-rw-r--r--Tools/px4params/xmlout.py22
-rwxr-xr-xTools/px_mkfw.py8
-rwxr-xr-xTools/px_uploader.py121
-rw-r--r--Tools/sdlog2_dump.py25
-rw-r--r--Tools/tests-host/.gitignore2
-rw-r--r--Tools/tests-host/Makefile39
-rw-r--r--Tools/tests-host/arch/board/board.h0
-rw-r--r--Tools/tests-host/mixer_test.cpp12
-rw-r--r--Tools/tests-host/nuttx/config.h0
16 files changed, 535 insertions, 52 deletions
diff --git a/Tools/px4params/.gitignore b/Tools/px4params/.gitignore
new file mode 100644
index 000000000..73cf39575
--- /dev/null
+++ b/Tools/px4params/.gitignore
@@ -0,0 +1,2 @@
+parameters.wiki
+parameters.xml \ No newline at end of file
diff --git a/Tools/px4params/README.md b/Tools/px4params/README.md
new file mode 100644
index 000000000..a23b44799
--- /dev/null
+++ b/Tools/px4params/README.md
@@ -0,0 +1,9 @@
+h1. PX4 Parameters Processor
+
+It's designed to scan PX4 source codes, find declarations of tunable parameters,
+and generate the list in various formats.
+
+Currently supported formats are:
+
+* XML for the parametric UI generator
+* Human-readable description in DokuWiki format
diff --git a/Tools/px4params/dokuwikiout.py b/Tools/px4params/dokuwikiout.py
new file mode 100644
index 000000000..33f76b415
--- /dev/null
+++ b/Tools/px4params/dokuwikiout.py
@@ -0,0 +1,27 @@
+import output
+
+class DokuWikiOutput(output.Output):
+ def Generate(self, groups):
+ result = ""
+ for group in groups:
+ result += "==== %s ====\n\n" % group.GetName()
+ for param in group.GetParams():
+ code = param.GetFieldValue("code")
+ name = param.GetFieldValue("short_desc")
+ if code != name:
+ name = "%s (%s)" % (name, code)
+ result += "=== %s ===\n\n" % name
+ long_desc = param.GetFieldValue("long_desc")
+ if long_desc is not None:
+ result += "%s\n\n" % long_desc
+ min_val = param.GetFieldValue("min")
+ if min_val is not None:
+ result += "* Minimal value: %s\n" % min_val
+ max_val = param.GetFieldValue("max")
+ if max_val is not None:
+ result += "* Maximal value: %s\n" % max_val
+ def_val = param.GetFieldValue("default")
+ if def_val is not None:
+ result += "* Default value: %s\n" % def_val
+ result += "\n"
+ return result
diff --git a/Tools/px4params/output.py b/Tools/px4params/output.py
new file mode 100644
index 000000000..c09246871
--- /dev/null
+++ b/Tools/px4params/output.py
@@ -0,0 +1,5 @@
+class Output(object):
+ def Save(self, groups, fn):
+ data = self.Generate(groups)
+ with open(fn, 'w') as f:
+ f.write(data)
diff --git a/Tools/px4params/parser.py b/Tools/px4params/parser.py
new file mode 100644
index 000000000..251be672f
--- /dev/null
+++ b/Tools/px4params/parser.py
@@ -0,0 +1,220 @@
+import sys
+import re
+
+class ParameterGroup(object):
+ """
+ Single parameter group
+ """
+ def __init__(self, name):
+ self.name = name
+ self.params = []
+
+ def AddParameter(self, param):
+ """
+ Add parameter to the group
+ """
+ self.params.append(param)
+
+ def GetName(self):
+ """
+ Get parameter group name
+ """
+ return self.name
+
+ def GetParams(self):
+ """
+ Returns the parsed list of parameters. Every parameter is a Parameter
+ object. Note that returned object is not a copy. Modifications affect
+ state of the parser.
+ """
+ return sorted(self.params,
+ cmp=lambda x, y: cmp(x.GetFieldValue("code"),
+ y.GetFieldValue("code")))
+
+class Parameter(object):
+ """
+ Single parameter
+ """
+
+ # Define sorting order of the fields
+ priority = {
+ "code": 10,
+ "type": 9,
+ "short_desc": 8,
+ "long_desc": 7,
+ "default": 6,
+ "min": 5,
+ "max": 4,
+ # all others == 0 (sorted alphabetically)
+ }
+
+ def __init__(self):
+ self.fields = {}
+
+ def SetField(self, code, value):
+ """
+ Set named field value
+ """
+ self.fields[code] = value
+
+ def GetFieldCodes(self):
+ """
+ Return list of existing field codes in convenient order
+ """
+ return sorted(self.fields.keys(),
+ cmp=lambda x, y: cmp(self.priority.get(y, 0),
+ self.priority.get(x, 0)) or cmp(x, y))
+
+ def GetFieldValue(self, code):
+ """
+ Return value of the given field code or None if not found.
+ """
+ return self.fields.get(code)
+
+class Parser(object):
+ """
+ Parses provided data and stores all found parameters internally.
+ """
+
+ re_split_lines = re.compile(r'[\r\n]+')
+ re_comment_start = re.compile(r'^\/\*\*')
+ re_comment_content = re.compile(r'^\*\s*(.*)')
+ re_comment_tag = re.compile(r'@([a-zA-Z][a-zA-Z0-9_]*)\s*(.*)')
+ re_comment_end = re.compile(r'(.*?)\s*\*\/')
+ re_parameter_definition = re.compile(r'PARAM_DEFINE_([A-Z_][A-Z0-9_]*)\s*\(([A-Z_][A-Z0-9_]*)\s*,\s*([^ ,\)]+)\s*\)\s*;')
+ re_cut_type_specifier = re.compile(r'[a-z]+$')
+ re_is_a_number = re.compile(r'^-?[0-9\.]')
+ re_remove_dots = re.compile(r'\.+$')
+
+ valid_tags = set(["min", "max", "group"])
+
+ # Order of parameter groups
+ priority = {
+ # All other groups = 0 (sort alphabetically)
+ "Miscellaneous": -10
+ }
+
+ def __init__(self):
+ self.param_groups = {}
+
+ def GetSupportedExtensions(self):
+ """
+ Returns list of supported file extensions that can be parsed by this
+ parser.
+ """
+ return ["cpp", "c"]
+
+ def Parse(self, contents):
+ """
+ Incrementally parse program contents and append all found parameters
+ to the list.
+ """
+ # This code is essentially a comment-parsing grammar. "state"
+ # represents parser state. It contains human-readable state
+ # names.
+ state = None
+ for line in self.re_split_lines.split(contents):
+ line = line.strip()
+ # Ignore empty lines
+ if line == "":
+ continue
+ if self.re_comment_start.match(line):
+ state = "wait-short"
+ short_desc = None
+ long_desc = None
+ tags = {}
+ elif state is not None and state != "comment-processed":
+ m = self.re_comment_end.search(line)
+ if m:
+ line = m.group(1)
+ last_comment_line = True
+ else:
+ last_comment_line = False
+ m = self.re_comment_content.match(line)
+ if m:
+ comment_content = m.group(1)
+ if comment_content == "":
+ # When short comment ends with empty comment line,
+ # start waiting for the next part - long comment.
+ if state == "wait-short-end":
+ state = "wait-long"
+ else:
+ m = self.re_comment_tag.match(comment_content)
+ if m:
+ tag, desc = m.group(1, 2)
+ tags[tag] = desc
+ current_tag = tag
+ state = "wait-tag-end"
+ elif state == "wait-short":
+ # Store first line of the short description
+ short_desc = comment_content
+ state = "wait-short-end"
+ elif state == "wait-short-end":
+ # Append comment line to the short description
+ short_desc += "\n" + comment_content
+ elif state == "wait-long":
+ # Store first line of the long description
+ long_desc = comment_content
+ state = "wait-long-end"
+ elif state == "wait-long-end":
+ # Append comment line to the long description
+ long_desc += "\n" + comment_content
+ elif state == "wait-tag-end":
+ # Append comment line to the tag text
+ tags[current_tag] += "\n" + comment_content
+ else:
+ raise AssertionError(
+ "Invalid parser state: %s" % state)
+ elif not last_comment_line:
+ # Invalid comment line (inside comment, but not starting with
+ # "*" or "*/". Reset parsed content.
+ state = None
+ if last_comment_line:
+ state = "comment-processed"
+ else:
+ # Non-empty line outside the comment
+ m = self.re_parameter_definition.match(line)
+ if m:
+ tp, code, defval = m.group(1, 2, 3)
+ # Remove trailing type specifier from numbers: 0.1f => 0.1
+ if self.re_is_a_number.match(defval):
+ defval = self.re_cut_type_specifier.sub('', defval)
+ param = Parameter()
+ param.SetField("code", code)
+ param.SetField("short_desc", code)
+ param.SetField("type", tp)
+ param.SetField("default", defval)
+ # If comment was found before the parameter declaration,
+ # inject its data into the newly created parameter.
+ group = "Miscellaneous"
+ if state == "comment-processed":
+ if short_desc is not None:
+ param.SetField("short_desc",
+ self.re_remove_dots.sub('', short_desc))
+ if long_desc is not None:
+ param.SetField("long_desc", long_desc)
+ for tag in tags:
+ if tag == "group":
+ group = tags[tag]
+ elif tag not in self.valid_tags:
+ sys.stderr.write("Skipping invalid"
+ "documentation tag: '%s'\n" % tag)
+ else:
+ param.SetField(tag, tags[tag])
+ # Store the parameter
+ if group not in self.param_groups:
+ self.param_groups[group] = ParameterGroup(group)
+ self.param_groups[group].AddParameter(param)
+ # Reset parsed comment.
+ state = None
+
+ def GetParamGroups(self):
+ """
+ Returns the parsed list of parameters. Every parameter is a Parameter
+ object. Note that returned object is not a copy. Modifications affect
+ state of the parser.
+ """
+ return sorted(self.param_groups.values(),
+ cmp=lambda x, y: cmp(self.priority.get(y.GetName(), 0),
+ self.priority.get(x.GetName(), 0)) or cmp(x.GetName(),
+ y.GetName()))
diff --git a/Tools/px4params/px_process_params.py b/Tools/px4params/px_process_params.py
new file mode 100755
index 000000000..cdf5aba7c
--- /dev/null
+++ b/Tools/px4params/px_process_params.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+############################################################################
+#
+# Copyright (C) 2013 PX4 Development Team. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# 3. Neither the name PX4 nor the names of its contributors may be
+# used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
+#
+# PX4 paramers processor (main executable file)
+#
+# It scans src/ subdirectory of the project, collects all parameters
+# definitions, and outputs list of parameters in XML and DokuWiki formats.
+#
+
+import scanner
+import parser
+import xmlout
+import dokuwikiout
+
+# Initialize parser
+prs = parser.Parser()
+
+# Scan directories, and parse the files
+sc = scanner.Scanner()
+sc.ScanDir("../../src", prs)
+output = prs.GetParamGroups()
+
+# Output into XML
+out = xmlout.XMLOutput()
+out.Save(output, "parameters.xml")
+
+# Output into DokuWiki
+out = dokuwikiout.DokuWikiOutput()
+out.Save(output, "parameters.wiki")
diff --git a/Tools/px4params/scanner.py b/Tools/px4params/scanner.py
new file mode 100644
index 000000000..b5a1af47c
--- /dev/null
+++ b/Tools/px4params/scanner.py
@@ -0,0 +1,34 @@
+import os
+import re
+
+class Scanner(object):
+ """
+ Traverses directory tree, reads all source files, and passes their contents
+ to the Parser.
+ """
+
+ re_file_extension = re.compile(r'\.([^\.]+)$')
+
+ def ScanDir(self, srcdir, parser):
+ """
+ Scans provided path and passes all found contents to the parser using
+ parser.Parse method.
+ """
+ extensions = set(parser.GetSupportedExtensions())
+ for dirname, dirnames, filenames in os.walk(srcdir):
+ for filename in filenames:
+ m = self.re_file_extension.search(filename)
+ if m:
+ ext = m.group(1)
+ if ext in extensions:
+ path = os.path.join(dirname, filename)
+ self.ScanFile(path, parser)
+
+ def ScanFile(self, path, parser):
+ """
+ Scans provided file and passes its contents to the parser using
+ parser.Parse method.
+ """
+ with open(path, 'r') as f:
+ contents = f.read()
+ parser.Parse(contents)
diff --git a/Tools/px4params/xmlout.py b/Tools/px4params/xmlout.py
new file mode 100644
index 000000000..d56802b15
--- /dev/null
+++ b/Tools/px4params/xmlout.py
@@ -0,0 +1,22 @@
+import output
+from xml.dom.minidom import getDOMImplementation
+
+class XMLOutput(output.Output):
+ def Generate(self, groups):
+ impl = getDOMImplementation()
+ xml_document = impl.createDocument(None, "parameters", None)
+ xml_parameters = xml_document.documentElement
+ for group in groups:
+ xml_group = xml_document.createElement("group")
+ xml_group.setAttribute("name", group.GetName())
+ xml_parameters.appendChild(xml_group)
+ for param in group.GetParams():
+ xml_param = xml_document.createElement("parameter")
+ xml_group.appendChild(xml_param)
+ for code in param.GetFieldCodes():
+ value = param.GetFieldValue(code)
+ xml_field = xml_document.createElement(code)
+ xml_param.appendChild(xml_field)
+ xml_value = xml_document.createTextNode(value)
+ xml_field.appendChild(xml_value)
+ return xml_document.toprettyxml(indent=" ", newl="\n", encoding="utf-8")
diff --git a/Tools/px_mkfw.py b/Tools/px_mkfw.py
index faef9ca33..b598a65a1 100755
--- a/Tools/px_mkfw.py
+++ b/Tools/px_mkfw.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
############################################################################
#
-# Copyright (C) 2012 PX4 Development Team. All rights reserved.
+# Copyright (C) 2012, 2013 PX4 Development Team. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -60,7 +60,7 @@ def mkdesc():
proto['description'] = ""
proto['git_identity'] = ""
proto['build_time'] = 0
- proto['image'] = base64.b64encode(bytearray())
+ proto['image'] = bytes()
proto['image_size'] = 0
return proto
@@ -99,12 +99,12 @@ if args.description != None:
if args.git_identity != None:
cmd = " ".join(["git", "--git-dir", args.git_identity + "/.git", "describe", "--always", "--dirty"])
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout
- desc['git_identity'] = p.read().strip()
+ desc['git_identity'] = str(p.read().strip())
p.close()
if args.image != None:
f = open(args.image, "rb")
bytes = f.read()
desc['image_size'] = len(bytes)
- desc['image'] = base64.b64encode(zlib.compress(bytes,9))
+ desc['image'] = base64.b64encode(zlib.compress(bytes,9)).decode('utf-8')
print(json.dumps(desc, indent=4))
diff --git a/Tools/px_uploader.py b/Tools/px_uploader.py
index d2ebf1698..a2d7d371d 100755
--- a/Tools/px_uploader.py
+++ b/Tools/px_uploader.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
############################################################################
#
-# Copyright (C) 2012 PX4 Development Team. All rights reserved.
+# Copyright (C) 2012, 2013 PX4 Development Team. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -102,7 +102,7 @@ class firmware(object):
0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d])
- crcpad = bytearray('\xff\xff\xff\xff')
+ crcpad = bytearray(b'\xff\xff\xff\xff')
def __init__(self, path):
@@ -137,34 +137,40 @@ class uploader(object):
'''Uploads a firmware file to the PX FMU bootloader'''
# protocol bytes
- INSYNC = chr(0x12)
- EOC = chr(0x20)
+ INSYNC = b'\x12'
+ EOC = b'\x20'
# reply bytes
- OK = chr(0x10)
- FAILED = chr(0x11)
- INVALID = chr(0x13) # rev3+
+ OK = b'\x10'
+ FAILED = b'\x11'
+ INVALID = b'\x13' # rev3+
# command bytes
- NOP = chr(0x00) # guaranteed to be discarded by the bootloader
- GET_SYNC = chr(0x21)
- GET_DEVICE = chr(0x22)
- CHIP_ERASE = chr(0x23)
- CHIP_VERIFY = chr(0x24) # rev2 only
- PROG_MULTI = chr(0x27)
- READ_MULTI = chr(0x28) # rev2 only
- GET_CRC = chr(0x29) # rev3+
- REBOOT = chr(0x30)
+ NOP = b'\x00' # guaranteed to be discarded by the bootloader
+ GET_SYNC = b'\x21'
+ GET_DEVICE = b'\x22'
+ CHIP_ERASE = b'\x23'
+ CHIP_VERIFY = b'\x24' # rev2 only
+ PROG_MULTI = b'\x27'
+ READ_MULTI = b'\x28' # rev2 only
+ GET_CRC = b'\x29' # rev3+
+ REBOOT = b'\x30'
- INFO_BL_REV = chr(1) # bootloader protocol revision
+ INFO_BL_REV = b'\x01' # bootloader protocol revision
BL_REV_MIN = 2 # minimum supported bootloader protocol
- BL_REV_MAX = 3 # maximum supported bootloader protocol
- INFO_BOARD_ID = chr(2) # board type
- INFO_BOARD_REV = chr(3) # board revision
- INFO_FLASH_SIZE = chr(4) # max firmware size in bytes
+ BL_REV_MAX = 4 # maximum supported bootloader protocol
+ INFO_BOARD_ID = b'\x02' # board type
+ INFO_BOARD_REV = b'\x03' # board revision
+ INFO_FLASH_SIZE = b'\x04' # max firmware size in bytes
PROG_MULTI_MAX = 60 # protocol max is 255, must be multiple of 4
READ_MULTI_MAX = 60 # protocol max is 255, something overflows with >= 64
+
+ NSH_INIT = bytearray(b'\x0d\x0d\x0d')
+ NSH_REBOOT_BL = b"reboot -b\n"
+ NSH_REBOOT = b"reboot\n"
+ MAVLINK_REBOOT_ID1 = bytearray(b'\xfe\x21\x72\xff\x00\x4c\x00\x00\x80\x3f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\x00\x01\x00\x00\x48\xf0')
+ MAVLINK_REBOOT_ID0 = bytearray(b'\xfe\x21\x45\xff\x00\x4c\x00\x00\x80\x3f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\x00\x00\x00\x00\xd7\xac')
def __init__(self, portname, baudrate):
# open the port, keep the default timeout short so we can poll quickly
@@ -176,7 +182,7 @@ class uploader(object):
def __send(self, c):
# print("send " + binascii.hexlify(c))
- self.port.write(str(c))
+ self.port.write(c)
def __recv(self, count=1):
c = self.port.read(count)
@@ -192,9 +198,9 @@ class uploader(object):
def __getSync(self):
self.port.flush()
- c = self.__recv()
- if c is not self.INSYNC:
- raise RuntimeError("unexpected 0x%x instead of INSYNC" % ord(c))
+ c = bytes(self.__recv())
+ if c != self.INSYNC:
+ raise RuntimeError("unexpected %s instead of INSYNC" % c)
c = self.__recv()
if c == self.INVALID:
raise RuntimeError("bootloader reports INVALID OPERATION")
@@ -249,17 +255,29 @@ class uploader(object):
# send a PROG_MULTI command to write a collection of bytes
def __program_multi(self, data):
- self.__send(uploader.PROG_MULTI
- + chr(len(data)))
+
+ if runningPython3 == True:
+ length = len(data).to_bytes(1, byteorder='big')
+ else:
+ length = chr(len(data))
+
+ self.__send(uploader.PROG_MULTI)
+ self.__send(length)
self.__send(data)
self.__send(uploader.EOC)
self.__getSync()
# verify multiple bytes in flash
def __verify_multi(self, data):
- self.__send(uploader.READ_MULTI
- + chr(len(data))
- + uploader.EOC)
+
+ if runningPython3 == True:
+ length = len(data).to_bytes(1, byteorder='big')
+ else:
+ length = chr(len(data))
+
+ self.__send(uploader.READ_MULTI)
+ self.__send(length)
+ self.__send(uploader.EOC)
self.port.flush()
programmed = self.__recv(len(data))
if programmed != data:
@@ -350,7 +368,24 @@ class uploader(object):
print("done, rebooting.")
self.__reboot()
self.port.close()
-
+
+ def send_reboot(self):
+ # try reboot via NSH first
+ self.__send(uploader.NSH_INIT)
+ self.__send(uploader.NSH_REBOOT_BL)
+ self.__send(uploader.NSH_INIT)
+ self.__send(uploader.NSH_REBOOT)
+ # then try MAVLINK command
+ self.__send(uploader.MAVLINK_REBOOT_ID1)
+ self.__send(uploader.MAVLINK_REBOOT_ID0)
+
+
+
+# Detect python version
+if sys.version_info[0] < 3:
+ runningPython3 = False
+else:
+ runningPython3 = True
# Parse commandline arguments
parser = argparse.ArgumentParser(description="Firmware uploader for the PX autopilot system.")
@@ -365,7 +400,19 @@ print("Loaded firmware for %x,%x, waiting for the bootloader..." % (fw.property(
# Spin waiting for a device to show up
while True:
- for port in args.port.split(","):
+ portlist = []
+ patterns = args.port.split(",")
+ # on unix-like platforms use glob to support wildcard ports. This allows
+ # the use of /dev/serial/by-id/usb-3D_Robotics on Linux, which prevents the upload from
+ # causing modem hangups etc
+ if "linux" in _platform or "darwin" in _platform:
+ import glob
+ for pattern in patterns:
+ portlist += glob.glob(pattern)
+ else:
+ portlist = patterns
+
+ for port in portlist:
#print("Trying %s" % port)
@@ -383,7 +430,7 @@ while True:
# Windows, don't open POSIX ports
if not "/" in port:
up = uploader(port, args.baud)
- except:
+ except Exception:
# open failed, rate-limit our attempts
time.sleep(0.05)
@@ -396,8 +443,12 @@ while True:
up.identify()
print("Found board %x,%x bootloader rev %x on %s" % (up.board_type, up.board_rev, up.bl_rev, port))
- except:
- # most probably a timeout talking to the port, no bootloader
+ except Exception:
+ # most probably a timeout talking to the port, no bootloader, try to reboot the board
+ print("attempting reboot on %s..." % port)
+ up.send_reboot()
+ # wait for the reboot, without we might run into Serial I/O Error 5
+ time.sleep(0.5)
continue
try:
diff --git a/Tools/sdlog2_dump.py b/Tools/sdlog2_dump.py
index 7fefc5908..5b1e55e22 100644
--- a/Tools/sdlog2_dump.py
+++ b/Tools/sdlog2_dump.py
@@ -25,8 +25,12 @@ import struct, sys
if sys.hexversion >= 0x030000F0:
runningPython3 = True
+ def _parseCString(cstr):
+ return str(cstr, 'ascii').split('\0')[0]
else:
runningPython3 = False
+ def _parseCString(cstr):
+ return str(cstr).split('\0')[0]
class SDLog2Parser:
BLOCK_SIZE = 8192
@@ -175,9 +179,9 @@ class SDLog2Parser:
self.__csv_columns.append(full_label)
self.__csv_data[full_label] = None
if self.__file != None:
- print(self.__csv_delim.join(self.__csv_columns), file=self.__file)
+ print(self.__csv_delim.join(self.__csv_columns), file=self.__file)
else:
- print(self.__csv_delim.join(self.__csv_columns))
+ print(self.__csv_delim.join(self.__csv_columns))
def __printCSVRow(self):
s = []
@@ -190,9 +194,9 @@ class SDLog2Parser:
s.append(v)
if self.__file != None:
- print(self.__csv_delim.join(s), file=self.__file)
+ print(self.__csv_delim.join(s), file=self.__file)
else:
- print(self.__csv_delim.join(s))
+ print(self.__csv_delim.join(s))
def __parseMsgDescr(self):
if runningPython3:
@@ -202,14 +206,9 @@ class SDLog2Parser:
msg_type = data[0]
if msg_type != self.MSG_TYPE_FORMAT:
msg_length = data[1]
- if runningPython3:
- msg_name = str(data[2], 'ascii').strip("\0")
- msg_format = str(data[3], 'ascii').strip("\0")
- msg_labels = str(data[4], 'ascii').strip("\0").split(",")
- else:
- msg_name = str(data[2]).strip("\0")
- msg_format = str(data[3]).strip("\0")
- msg_labels = str(data[4]).strip("\0").split(",")
+ msg_name = _parseCString(data[2])
+ msg_format = _parseCString(data[3])
+ msg_labels = _parseCString(data[4]).split(",")
# Convert msg_format to struct.unpack format string
msg_struct = ""
msg_mults = []
@@ -243,7 +242,7 @@ class SDLog2Parser:
data = list(struct.unpack(msg_struct, str(self.__buffer[self.__ptr+self.MSG_HEADER_LEN:self.__ptr+msg_length])))
for i in range(len(data)):
if type(data[i]) is str:
- data[i] = data[i].strip("\0")
+ data[i] = _parseCString(data[i])
m = msg_mults[i]
if m != None:
data[i] = data[i] * m
diff --git a/Tools/tests-host/.gitignore b/Tools/tests-host/.gitignore
new file mode 100644
index 000000000..61e091551
--- /dev/null
+++ b/Tools/tests-host/.gitignore
@@ -0,0 +1,2 @@
+./obj/*
+mixer_test
diff --git a/Tools/tests-host/Makefile b/Tools/tests-host/Makefile
new file mode 100644
index 000000000..97410ff47
--- /dev/null
+++ b/Tools/tests-host/Makefile
@@ -0,0 +1,39 @@
+
+CC=g++
+CFLAGS=-I. -I../../src/modules -I ../../src/include -I../../src/drivers -I../../src -D__EXPORT="" -Dnullptr="0"
+
+ODIR=obj
+LDIR =../lib
+
+LIBS=-lm
+
+#_DEPS = test.h
+#DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
+
+_OBJ = mixer_test.o test_mixer.o mixer_simple.o mixer_multirotor.o mixer.o mixer_group.o mixer_load.o
+OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
+
+#$(DEPS)
+$(ODIR)/%.o: %.cpp
+ $(CC) -c -o $@ $< $(CFLAGS)
+
+$(ODIR)/%.o: ../../src/systemcmds/tests/%.cpp
+ $(CC) -c -o $@ $< $(CFLAGS)
+
+$(ODIR)/%.o: ../../src/modules/systemlib/%.cpp
+ $(CC) -c -o $@ $< $(CFLAGS)
+
+$(ODIR)/%.o: ../../src/modules/systemlib/mixer/%.cpp
+ $(CC) -c -o $@ $< $(CFLAGS)
+
+$(ODIR)/%.o: ../../src/modules/systemlib/mixer/%.c
+ $(CC) -c -o $@ $< $(CFLAGS)
+
+#
+mixer_test: $(OBJ)
+ g++ -o $@ $^ $(CFLAGS) $(LIBS)
+
+.PHONY: clean
+
+clean:
+ rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~ \ No newline at end of file
diff --git a/Tools/tests-host/arch/board/board.h b/Tools/tests-host/arch/board/board.h
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tools/tests-host/arch/board/board.h
diff --git a/Tools/tests-host/mixer_test.cpp b/Tools/tests-host/mixer_test.cpp
new file mode 100644
index 000000000..042322aad
--- /dev/null
+++ b/Tools/tests-host/mixer_test.cpp
@@ -0,0 +1,12 @@
+#include <systemlib/mixer/mixer.h>
+#include <systemlib/err.h>
+#include "../../src/systemcmds/tests/tests.h"
+
+int main(int argc, char *argv[]) {
+ warnx("Host execution started");
+
+ char* args[] = {argv[0], "../../ROMFS/px4fmu_common/mixers/IO_pass.mix",
+ "../../ROMFS/px4fmu_common/mixers/FMU_quad_w.mix"};
+
+ test_mixer(3, args);
+} \ No newline at end of file
diff --git a/Tools/tests-host/nuttx/config.h b/Tools/tests-host/nuttx/config.h
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tools/tests-host/nuttx/config.h