def check_binary(fdesc, binary, base_address, destinations): """ Check that the binary was correctly written to all destinations. Returns a list of all nodes which are passing the test. """ valid_nodes = [] expected_crc = crc32(binary) command = commands.encode_crc_region(base_address, len(binary)) utils.write_command(fdesc, command, destinations) reader = utils.read_can_datagrams(fdesc) boards_checked = 0 while boards_checked < len(destinations): dt = next(reader) if dt is None: continue answer, _, src = dt crc = msgpack.unpackb(answer) if crc == expected_crc: valid_nodes.append(src) boards_checked += 1 return valid_nodes
def main(): args = parse_commandline_args() connection = utils.open_connection(args) if args.all: scan_queue = list() # Broadcast ping utils.write_command(connection, commands.encode_ping(), list(range(1, 128))) reader = utils.read_can_datagrams(connection) while True: dt = next(reader) if dt is None: # Timeout break _, _, src = dt scan_queue.append(src) else: scan_queue = args.ids # Broadcast ask for config configs = utils.write_command_retry(connection, commands.encode_read_config(), scan_queue) for id, raw_config in configs.items(): configs[id] = msgpack.unpackb(raw_config, encoding="ascii") print(json.dumps(configs, indent=4, sort_keys=True))
def main(): args = parse_commandline_args() connection = utils.open_connection(args) if args.all: scan_queue = list() # Broadcast ping utils.write_command(connection, commands.encode_ping(), list(range(1, 128))) reader = utils.read_can_datagrams(connection) while True: dt = next(reader) if dt is None: # Timeout break _, _, src = dt scan_queue.append(src) else: scan_queue = args.ids # Broadcast ask for config configs = utils.write_command_retry(connection, commands.encode_read_config(), scan_queue) for id, raw_config in configs.items(): configs[id] = msgpack.unpackb(raw_config, encoding='ascii') print(json.dumps(configs, indent=4, sort_keys=True))
def main(): args = parse_commandline_args() connection = utils.open_connection(args) if args.all is True: ids = list(range(1, 128)) else: ids = args.ids utils.write_command(connection, commands.encode_jump_to_main(), ids)
def check_online_boards(fdesc, boards): """ Returns a set containing the online boards. """ online_boards = set() utils.write_command(fdesc, commands.encode_ping(), boards) reader = utils.read_can_datagrams(fdesc) for dt in reader: if dt is None: break _, _, src = dt online_boards.add(src) return online_boards
def run_application(fdesc, destinations): """ Asks the given node to run the application. """ command = commands.encode_jump_to_main() utils.write_command(fdesc, command, destinations)