Tools: use chibios_hwdef lib to determine is-ap-periph
This commit is contained in:
parent
586851e40f
commit
01c3e34eea
@ -12,6 +12,10 @@ import shutil
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
# modify our search path:
|
||||||
|
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../libraries/AP_HAL_ChibiOS/hwdef/scripts'))
|
||||||
|
import chibios_hwdef
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='configure all ChibiOS boards')
|
parser = argparse.ArgumentParser(description='configure all ChibiOS boards')
|
||||||
parser.add_argument('--build', action='store_true', default=False, help='build as well as configure')
|
parser.add_argument('--build', action='store_true', default=False, help='build as well as configure')
|
||||||
parser.add_argument('--build-target', default='copter', help='build target')
|
parser.add_argument('--build-target', default='copter', help='build target')
|
||||||
@ -66,14 +70,9 @@ if args.start is not None:
|
|||||||
|
|
||||||
def is_ap_periph(board):
|
def is_ap_periph(board):
|
||||||
hwdef = os.path.join('libraries/AP_HAL_ChibiOS/hwdef/%s/hwdef.dat' % board)
|
hwdef = os.path.join('libraries/AP_HAL_ChibiOS/hwdef/%s/hwdef.dat' % board)
|
||||||
try:
|
ch = chibios_hwdef.ChibiOSHWDef()
|
||||||
r = open(hwdef, 'r').read()
|
ch.process_file(hwdef)
|
||||||
if r.find('periph/hwdef.dat') != -1 or r.find('periph/hwdef.inc') != -1 or r.find('AP_PERIPH') != -1:
|
return ch.is_periph_fw()
|
||||||
print("%s is AP_Periph" % board)
|
|
||||||
return True
|
|
||||||
except Exception as ex:
|
|
||||||
pass
|
|
||||||
return False
|
|
||||||
|
|
||||||
if args.copy_hwdef_incs_to_directory is not None:
|
if args.copy_hwdef_incs_to_directory is not None:
|
||||||
os.makedirs(args.copy_hwdef_incs_to_directory)
|
os.makedirs(args.copy_hwdef_incs_to_directory)
|
||||||
|
Loading…
Reference in New Issue
Block a user