mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 01:12:31 +00:00
Merge pull request #1734 from PX4/ros_messagelayer_merge_attctrl_posctrl
Ros messagelayer merge attctrl posctrl
This commit is contained in:
36
Tools/make_color.sh
Executable file
36
Tools/make_color.sh
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
# make_color.sh
|
||||
#
|
||||
# Author: Simon Wilks (simon@uaventure.com)
|
||||
#
|
||||
# A compiler color coder.
|
||||
#
|
||||
# To invoke this script everytime you run make simply create the alias:
|
||||
#
|
||||
# alias make='<your-firmware-directory>/Tools/make_color.sh'
|
||||
#
|
||||
# Color codes:
|
||||
#
|
||||
# white "\033[1,37m"
|
||||
# yellow "\033[1,33m"
|
||||
# green "\033[1,32m"
|
||||
# blue "\033[1,34m"
|
||||
# cyan "\033[1,36m"
|
||||
# red "\033[1,31m"
|
||||
# magenta "\033[1,35m"
|
||||
# black "\033[1,30m"
|
||||
# darkwhite "\033[0,37m"
|
||||
# darkyellow "\033[0,33m"
|
||||
# darkgreen "\033[0,32m"
|
||||
# darkblue "\033[0,34m"
|
||||
# darkcyan "\033[0,36m"
|
||||
# darkred "\033[0,31m"
|
||||
# darkmagenta "\033[0,35m"
|
||||
# off "\033[0,0m"
|
||||
#
|
||||
OFF="\o033[0m"
|
||||
WARN="\o033[1;33m"
|
||||
ERROR="\o033[1;31m"
|
||||
INFO="\o033[0;37m"
|
||||
|
||||
make ${@} 2>&1 | sed "s/make\[[0-9]\].*/$INFO & $OFF/;s/.*: warning: .*/$WARN & $OFF/;s/.*: error: .*/$ERROR & $OFF/"
|
||||
@@ -60,7 +60,7 @@ def convert_file(filename, outputdir, templatedir, includepath):
|
||||
"""
|
||||
Converts a single .msg file to a uorb header
|
||||
"""
|
||||
print("Generating uORB headers from {0}".format(filename))
|
||||
print("Generating headers from {0}".format(filename))
|
||||
genmsg.template_tools.generate_from_file(filename,
|
||||
package,
|
||||
outputdir,
|
||||
@@ -85,16 +85,21 @@ def convert_dir(inputdir, outputdir, templatedir):
|
||||
includepath)
|
||||
|
||||
|
||||
def copy_changed(inputdir, outputdir):
|
||||
def copy_changed(inputdir, outputdir, prefix=''):
|
||||
"""
|
||||
Copies files from inputdir to outputdir if they don't exist in
|
||||
ouputdir or if their content changed
|
||||
"""
|
||||
|
||||
# Make sure output directory exists:
|
||||
if not os.path.isdir(outputdir):
|
||||
os.makedirs(outputdir)
|
||||
|
||||
for f in os.listdir(inputdir):
|
||||
fni = os.path.join(inputdir, f)
|
||||
if os.path.isfile(fni):
|
||||
# Check if f exists in outpoutdir, copy the file if not
|
||||
fno = os.path.join(outputdir, f)
|
||||
fno = os.path.join(outputdir, prefix + f)
|
||||
if not os.path.isfile(fno):
|
||||
shutil.copy(fni, fno)
|
||||
print("{0}: new header file".format(f))
|
||||
@@ -108,7 +113,8 @@ def copy_changed(inputdir, outputdir):
|
||||
|
||||
print("{0}: unchanged".format(f))
|
||||
|
||||
def convert_dir_save(inputdir, outputdir, templatedir, temporarydir):
|
||||
|
||||
def convert_dir_save(inputdir, outputdir, templatedir, temporarydir, prefix):
|
||||
"""
|
||||
Converts all .msg files in inputdir to uORB header files
|
||||
Unchanged existing files are not overwritten.
|
||||
@@ -117,7 +123,7 @@ def convert_dir_save(inputdir, outputdir, templatedir, temporarydir):
|
||||
convert_dir(inputdir, temporarydir, templatedir)
|
||||
|
||||
# Copy changed headers from temporary dir to output dir
|
||||
copy_changed(temporarydir, outputdir)
|
||||
copy_changed(temporarydir, outputdir, prefix)
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(
|
||||
@@ -132,6 +138,9 @@ if __name__ == "__main__":
|
||||
help='output directory for header files')
|
||||
parser.add_argument('-t', dest='temporarydir',
|
||||
help='temporary directory')
|
||||
parser.add_argument('-p', dest='prefix', default='',
|
||||
help='string added as prefix to the output file '
|
||||
' name when converting directories')
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.file is not None:
|
||||
@@ -146,4 +155,5 @@ if __name__ == "__main__":
|
||||
args.dir,
|
||||
args.outputdir,
|
||||
args.templatedir,
|
||||
args.temporarydir)
|
||||
args.temporarydir,
|
||||
args.prefix)
|
||||
|
||||
@@ -266,18 +266,19 @@ class uploader(object):
|
||||
self.__getSync()
|
||||
return value
|
||||
|
||||
def __drawProgressBar(self, progress, maxVal):
|
||||
def __drawProgressBar(self, label, progress, maxVal):
|
||||
if maxVal < progress:
|
||||
progress = maxVal
|
||||
|
||||
percent = (float(progress) / float(maxVal)) * 100.0
|
||||
|
||||
sys.stdout.write("\rprogress:[%-20s] %.2f%%" % ('='*int(percent/5.0), percent))
|
||||
sys.stdout.write("\r%s: [%-20s] %.1f%%" % (label, '='*int(percent/5.0), percent))
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
# send the CHIP_ERASE command and wait for the bootloader to become ready
|
||||
def __erase(self):
|
||||
def __erase(self, label):
|
||||
print("\n", end='')
|
||||
self.__send(uploader.CHIP_ERASE
|
||||
+ uploader.EOC)
|
||||
|
||||
@@ -288,15 +289,14 @@ class uploader(object):
|
||||
#Draw progress bar (erase usually takes about 9 seconds to complete)
|
||||
estimatedTimeRemaining = deadline-time.time()
|
||||
if estimatedTimeRemaining >= 9.0:
|
||||
self.__drawProgressBar(20.0-estimatedTimeRemaining, 9.0)
|
||||
self.__drawProgressBar(label, 20.0-estimatedTimeRemaining, 9.0)
|
||||
else:
|
||||
self.__drawProgressBar(10.0, 10.0)
|
||||
self.__drawProgressBar(label, 10.0, 10.0)
|
||||
sys.stdout.write(" (timeout: %d seconds) " % int(deadline-time.time()) )
|
||||
sys.stdout.flush()
|
||||
|
||||
if self.__trySync():
|
||||
self.__drawProgressBar(10.0, 10.0)
|
||||
sys.stdout.write("\nerase complete!\n")
|
||||
self.__drawProgressBar(label, 10.0, 10.0)
|
||||
return;
|
||||
|
||||
raise RuntimeError("timed out waiting for erase")
|
||||
@@ -350,7 +350,8 @@ class uploader(object):
|
||||
return [seq[i:i+length] for i in range(0, len(seq), length)]
|
||||
|
||||
# upload code
|
||||
def __program(self, fw):
|
||||
def __program(self, label, fw):
|
||||
print("\n", end='')
|
||||
code = fw.image
|
||||
groups = self.__split_len(code, uploader.PROG_MULTI_MAX)
|
||||
|
||||
@@ -361,31 +362,40 @@ class uploader(object):
|
||||
#Print upload progress (throttled, so it does not delay upload progress)
|
||||
uploadProgress += 1
|
||||
if uploadProgress % 256 == 0:
|
||||
self.__drawProgressBar(uploadProgress, len(groups))
|
||||
self.__drawProgressBar(100, 100)
|
||||
print("\nprogram complete!")
|
||||
self.__drawProgressBar(label, uploadProgress, len(groups))
|
||||
self.__drawProgressBar(label, 100, 100)
|
||||
|
||||
# verify code
|
||||
def __verify_v2(self, fw):
|
||||
def __verify_v2(self, label, fw):
|
||||
print("\n", end='')
|
||||
self.__send(uploader.CHIP_VERIFY
|
||||
+ uploader.EOC)
|
||||
self.__getSync()
|
||||
code = fw.image
|
||||
groups = self.__split_len(code, uploader.READ_MULTI_MAX)
|
||||
verifyProgress = 0
|
||||
for bytes in groups:
|
||||
verifyProgress += 1
|
||||
if verifyProgress % 256 == 0:
|
||||
self.__drawProgressBar(label, verifyProgress, len(groups))
|
||||
if (not self.__verify_multi(bytes)):
|
||||
raise RuntimeError("Verification failed")
|
||||
self.__drawProgressBar(label, 100, 100)
|
||||
|
||||
def __verify_v3(self, fw):
|
||||
expect_crc = fw.crc(self.fw_maxsize)
|
||||
def __verify_v3(self, label, fw):
|
||||
print("\n", end='')
|
||||
self.__drawProgressBar(label, 1, 100)
|
||||
expect_crc = fw.crc(self.fw_maxsize)
|
||||
self.__send(uploader.GET_CRC
|
||||
+ uploader.EOC)
|
||||
report_crc = self.__recv_int()
|
||||
self.__getSync()
|
||||
verifyProgress = 0
|
||||
if report_crc != expect_crc:
|
||||
print("Expected 0x%x" % expect_crc)
|
||||
print("Got 0x%x" % report_crc)
|
||||
raise RuntimeError("Program CRC failed")
|
||||
self.__drawProgressBar(label, 100, 100)
|
||||
|
||||
# get basic data about the board
|
||||
def identify(self):
|
||||
@@ -439,19 +449,16 @@ class uploader(object):
|
||||
except Exception:
|
||||
# ignore bad character encodings
|
||||
pass
|
||||
print("erase...")
|
||||
self.__erase()
|
||||
|
||||
self.__erase("Erase ")
|
||||
self.__program("Program", fw)
|
||||
|
||||
print("program...")
|
||||
self.__program(fw)
|
||||
|
||||
print("verify...")
|
||||
if self.bl_rev == 2:
|
||||
self.__verify_v2(fw)
|
||||
self.__verify_v2("Verify ", fw)
|
||||
else:
|
||||
self.__verify_v3(fw)
|
||||
self.__verify_v3("Verify ", fw)
|
||||
|
||||
print("done, rebooting.")
|
||||
print("\nRebooting.\n")
|
||||
self.__reboot()
|
||||
self.port.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user