예제 #1
0
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
예제 #2
0
파일: web.py 프로젝트: Ryex/i2c-alarmpy
def alarm():
    if 'logged_in' in flask.session and flask.session['logged_in']:
        utils.write_command({"action": {
            "command": "alarm",
            "reason": "Web Interface Alarm"}})
        return flask.redirect(flask.url_for('dashboard'))
    return flask.abort(403)
예제 #3
0
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))
예제 #4
0
파일: web.py 프로젝트: Ryex/i2c-alarmpy
def alarm():
    if 'logged_in' in flask.session and flask.session['logged_in']:
        utils.write_command(
            {"action": {
                "command": "alarm",
                "reason": "Web Interface Alarm"
            }})
        return flask.redirect(flask.url_for('dashboard'))
    return flask.abort(403)
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)
예제 #6
0
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
예제 #7
0
파일: web.py 프로젝트: Ryex/i2c-alarmpy
def restart():
    if 'logged_in' in flask.session and flask.session['logged_in']:
        utils.write_command({"restart": "Web Interface Restart"})
        return flask.redirect(flask.url_for('dashboard'))
    return flask.abort(403)
예제 #8
0
파일: web.py 프로젝트: Ryex/i2c-alarmpy
def restart():
    if 'logged_in' in flask.session and flask.session['logged_in']:
        utils.write_command({"restart": "Web Interface Restart"})
        return flask.redirect(flask.url_for('dashboard'))
    return flask.abort(403)
예제 #9
0
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)