Skip to content

Commit

Permalink
tools/psoc6/get-devs.py: WIP adding hw_ext param.
Browse files Browse the repository at this point in the history
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
  • Loading branch information
jaenrig-ifx committed Feb 28, 2024
1 parent 60c3ad1 commit 6db4c69
Showing 1 changed file with 45 additions and 21 deletions.
66 changes: 45 additions & 21 deletions tools/psoc6/get-devs.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ def get_kitprog_serial_number(udevadm_output_lines):
return kitprog_devs


def get_devices_serial_num(board=None, devs_yml=None):
sn_list = []
def get_devices(serch_param, board=None, devs_yml=None):
dev_list = []
port_sn_map = udevadm_get_kitprog3_attached_devs()

if board is not None and devs_yml is not None:
Expand All @@ -100,33 +100,55 @@ def get_devices_serial_num(board=None, devs_yml=None):
for listed_board in board_sn_map:
if board == listed_board["board"]:
if dev["sn"] in listed_board["sn"]:
sn_list.append(dev["sn"])
dev_list.append(dev[serch_param])
break
else:
for dev in port_sn_map:
sn_list.append(dev["sn"])
dev_list.append(dev[serch_param])

return dev_list


def get_devices_serial_num(board=None, devs_yml=None):
return get_devices("sn", board, devs_yml)
# sn_list = []
# port_sn_map = udevadm_get_kitprog3_attached_devs()

return sn_list
# if board is not None and devs_yml is not None:
# board_sn_map = get_devs_from_yml(devs_yml)

# for dev in port_sn_map:
# for listed_board in board_sn_map:
# if board == listed_board["board"]:
# if dev["sn"] in listed_board["sn"]:
# sn_list.append(dev["sn"])
# break
# else:
# for dev in port_sn_map:
# sn_list.append(dev["sn"])

# return sn_list


def get_devices_port(board=None, devs_yml=None):
port_list = []
port_sn_map = udevadm_get_kitprog3_attached_devs()
return get_devices("port", board, devs_yml)
# port_list = []
# port_sn_map = udevadm_get_kitprog3_attached_devs()

if board is not None and devs_yml is not None:
board_sn_map = get_devs_from_yml(devs_yml)
# if board is not None and devs_yml is not None:
# board_sn_map = get_devs_from_yml(devs_yml)

for dev in port_sn_map:
for listed_board in board_sn_map:
if board == listed_board["board"]:
if dev["sn"] in listed_board["sn"]:
port_list.append(dev["port"])
break
else:
for dev in port_sn_map:
port_list.append(dev["port"])
# for dev in port_sn_map:
# for listed_board in board_sn_map:
# if board == listed_board["board"]:
# if dev["sn"] in listed_board["sn"]:
# port_list.append(dev["port"])
# break
# else:
# for dev in port_sn_map:
# port_list.append(dev["port"])

return port_list
# return port_list


def parser():
Expand All @@ -141,12 +163,12 @@ def parse_validate_opt_arg_mutual_required(args):

def parser_get_devices_serial_num(args):
parse_validate_opt_arg_mutual_required(args)
devs_serial = get_devices_serial_num(args.board, args.devs_yml)
devs_serial = get_devices_serial_num(args.board, args.devs_yml, args.hw_ext)
print(*devs_serial)

def parser_get_devices_port(args):
parse_validate_opt_arg_mutual_required(args)
devs_port = get_devices_port(args.board, args.devs_yml)
devs_port = get_devices_port(args.board, args.devs_yml, args.hw_ext)
print(*devs_port)

parser = argparse.ArgumentParser(description="Get kitprog3 device utility")
Expand All @@ -162,6 +184,7 @@ def parser_get_devices_port(args):
parser_sn.add_argument(
"-y", "--devs-yml", type=str, help="Device list yml with board - serial number map"
)
parser_sn.add_argument("--hw-ext", type=str, help="Required external hardware configuration")
parser_sn.set_defaults(func=parser_get_devices_serial_num)

# Get devices port
Expand All @@ -170,6 +193,7 @@ def parser_get_devices_port(args):
parser_port.add_argument(
"-y", "--devs-yml", type=str, help="Device list yml with board - serial number map"
)
parser_sn.add_argument("--hw-ext", type=str, help="Required external hardware configuration")
parser_port.set_defaults(func=parser_get_devices_port)

# Parser call
Expand Down

0 comments on commit 6db4c69

Please sign in to comment.