mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-23 00:04:02 -04:00
Tools: uploader.py: print board name as well as board id
This commit is contained in:
parent
1d9c2b1726
commit
539e73e49c
@ -65,6 +65,7 @@ import time
|
||||
import array
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
|
||||
from sys import platform as _platform
|
||||
|
||||
@ -672,11 +673,55 @@ class uploader(object):
|
||||
|
||||
print("Info:")
|
||||
print(" flash size: %u" % self.fw_maxsize)
|
||||
print(" board_type: %u" % self.board_type)
|
||||
name = self.board_name_for_board_id(self.board_type)
|
||||
if name is not None:
|
||||
print(" board_type: %u (%s)" % (self.board_type, name))
|
||||
else:
|
||||
print(" board_type: %u" % self.board_type)
|
||||
print(" board_rev: %u" % self.board_rev)
|
||||
|
||||
print("Identification complete")
|
||||
|
||||
def board_name_for_board_id(self, board_id):
|
||||
'''return name for board_id, None if it can't be found'''
|
||||
shared_ids = {
|
||||
9: "fmuv3",
|
||||
50: "fmuv5",
|
||||
}
|
||||
if board_id in shared_ids:
|
||||
return shared_ids[board_id]
|
||||
|
||||
try:
|
||||
ret = []
|
||||
|
||||
hwdef_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
|
||||
"..", "..", "libraries", "AP_HAL_ChibiOS", "hwdef")
|
||||
# uploader.py is swiped into other places, so if the dir
|
||||
# doesn't exist then fail silently
|
||||
if os.path.exists(hwdef_dir):
|
||||
dirs = [x if (x not in ["scripts","common","STM32CubeConf"] and os.path.isdir(os.path.join(hwdef_dir, x))) else None for x in os.listdir(hwdef_dir)]
|
||||
for adir in dirs:
|
||||
if adir is None:
|
||||
continue
|
||||
filepath = os.path.join(hwdef_dir, adir, "hwdef.dat")
|
||||
fh = open(filepath)
|
||||
if fh is None:
|
||||
# print("Failed to open (%s)" % filepath)
|
||||
continue
|
||||
text = fh.readlines()
|
||||
for line in text:
|
||||
m = re.match("^\s*APJ_BOARD_ID\s+(\d+)\s*$", line)
|
||||
if m is None:
|
||||
continue
|
||||
if int(m.group(1)) == board_id:
|
||||
ret.append(adir)
|
||||
if len(ret) == 0:
|
||||
return None
|
||||
return " or ".join(ret)
|
||||
except Exception as e:
|
||||
print("Failed to get name: %s" % str(e))
|
||||
return None
|
||||
|
||||
# upload the firmware
|
||||
def upload(self, fw, force=False, boot_delay=None):
|
||||
# Make sure we are doing the right thing
|
||||
|
Loading…
Reference in New Issue
Block a user