<commit_before>remarks:
    u16, etc.: MSB first
    a bool|b bool: 000000ab

commands:
    VERSION_REQ u8
    --> VERSION_REP u8, uc_id u96, hw_version u8, sw_version u8

    (asynchronous)
    --> SHUTDOWN u8

    (asynchronous)
    --> EMERGENCY_STOP u8

    EMERGENCY_ACTION u8, activate bool
    --> (status codes)

    EMERGENCY_REQ u8
    --> EMERGENCY_REP u8, active bool

    IO_CONFIG u8, port u8, on bool|pulldown bool|pullup bool|output bool
    --> (status codes)

    ANALOG_REQ u8, port u8
    --> ANALOG_REP u8, port u8, value u16
    --> (error codes)

    IMU_RATE_REQ u8
    --> IMU_RATE_REP u8, x s16, y s16, z s16

    IMU_ACCEL_REQ u8
    --> IMU_ACCEL_REP u8, x s16, y s16, z s16

    IMU_POSE_REQ u8
    --> IMU_POSE_REP u8, x s16, y s16, z s16

    DIGITAL_REQ u8, port u8
    --> DIGITAL_REP u8, port u8, value bool
    --> (error codes)

    MOTOR u8, port u8, mode u8, amount s16
    --> (status codes)

    MOTOR_POSITIONAL u8, port u8, mode u8, amount s16, relative bool|done_mode u7, position s32
    --> (status codes)

    MOTOR_SERVO u8, port u8, max_velocity u16, relative bool, position s32
    --> (status codes)

    MOTOR_CONFIG_DC u8, port u8
    --> (status codes)

    MOTOR_CONFIG_ENCODER u8, port u8, encoder_a_port u8, encoder_b_port u8
    --> (status codes)

    MOTOR_CONFIG_STEPPER u8, port u8
    --> (status codes)

    (asynchronous)
    --> MOTOR_DONE_UPDATE u8, port u8

    SERVO u8, port u8, active bool|value u15
    --> (status codes)

    UART u8, length u8, data u8{length}
    --> (status codes)

    (asynchronous)
    --> UART_UPDATE u8, length u8, data u8{length}

    SPEAKER u8, frequency u16
    --> (status codes)

status codes:
    OK u8
    UNKNOWN_OPCODE u8
    - the opcode is unknown and the connection needs to be reset
    INVALID_OPCODE u8
    - the opcode is known and is decoded properly, but can't be handled
    INVALID_PORT u8
    - port out of range
    - invalid port for stepper motor mode: only even port n is valid, odd port n+1 is affected as well
    INVALID_CONFIG u8
    - POWER(with value!=0)/BRAKE command for stepper motor
    - VELOCITY command for DC motor
    - IO_STATE command for encoder io port
    - motor command for auxiliary stepper motor port
    INVALID_MODE u8
    - mode is not POWER, BRAKE, VELOCITY
    INVALID_FLAGS u8
    - (io_flags & ~0x1F) != 0x00
    - invalid combination: OUTPUT & PULLUP/PULLDOWN; INPUT & ON; PULLUP & PULLDOWN
    INVALID_VALUE u8
    - MOTOR/SERVO value out of range

codes:
    command opcodes:
        VERSION_REQ             0x01
        EMERGENCY_ACTION        0x05
        EMERGENCY_REQ           0x06
        IO_CONFIG               0x10
        ANALOG_REQ              0x20
        IMU_RATE_REQ            0x22
        IMU_ACCEL_REQ           0x23
        IMU_POSE_REQ            0x24
        DIGITAL_REQ             0x30
        MOTOR                   0x40
        MOTOR_POSITIONAL        0x41
        MOTOR_SERVO             0x42
        MOTOR_CONFIG_DC         0x48
        MOTOR_CONFIG_ENCODER    0x49
        MOTOR_CONFIG_STEPPER    0x4A
        SERVO                   0x50
        UART                    0x60
        SPEAKER                 0x70
    reply opcodes:
        VERSION_REP             0x02
        EMERGENCY_REP           0x07
        OK                      0x80
        UNKNOWN_OPCODE          0x81
        INVALID_OPCODE          0x82
        INVALID_PORT            0x83
        INVALID_CONFIG          0x84
        INVALID_MODE            0x85
        INVALID_FLAGS           0x86
        INVALID_VALUE           0x87
        ANALOG_REP              0xA1
        IMU_RATE_REP            0xA2
        IMU_ACCEL_REP           0xA3
        IMU_POSE_REP            0xA4
        DIGITAL_REP             0xB1
    update opcodes:<commit_msg>added fail reply if emergency stop is active and motor or servo gets switched on<commit_after>remarks:
    u16, etc.: MSB first
    a bool|b bool: 000000ab

commands:
    VERSION_REQ u8
    --> VERSION_REP u8, uc_id u96, hw_version u8, sw_version u8

    (asynchronous)
    --> SHUTDOWN u8

    (asynchronous)
    --> EMERGENCY_STOP u8

    EMERGENCY_ACTION u8, activate bool
    --> (status codes)

    EMERGENCY_REQ u8
    --> EMERGENCY_REP u8, active bool

    IO_CONFIG u8, port u8, on bool|pulldown bool|pullup bool|output bool
    --> (status codes)

    ANALOG_REQ u8, port u8
    --> ANALOG_REP u8, port u8, value u16
    --> (error codes)

    IMU_RATE_REQ u8
    --> IMU_RATE_REP u8, x s16, y s16, z s16

    IMU_ACCEL_REQ u8
    --> IMU_ACCEL_REP u8, x s16, y s16, z s16

    IMU_POSE_REQ u8
    --> IMU_POSE_REP u8, x s16, y s16, z s16

    DIGITAL_REQ u8, port u8
    --> DIGITAL_REP u8, port u8, value bool
    --> (error codes)

    MOTOR u8, port u8, mode u8, amount s16
    --> (status codes)

    MOTOR_POSITIONAL u8, port u8, mode u8, amount s16, relative bool|done_mode u7, position s32
    --> (status codes)

    MOTOR_SERVO u8, port u8, max_velocity u16, relative bool, position s32
    --> (status codes)

    MOTOR_CONFIG_DC u8, port u8
    --> (status codes)

    MOTOR_CONFIG_ENCODER u8, port u8, encoder_a_port u8, encoder_b_port u8
    --> (status codes)

    MOTOR_CONFIG_STEPPER u8, port u8
    --> (status codes)

    (asynchronous)
    --> MOTOR_DONE_UPDATE u8, port u8

    SERVO u8, port u8, active bool|value u15
    --> (status codes)

    UART u8, length u8, data u8{length}
    --> (status codes)

    (asynchronous)
    --> UART_UPDATE u8, length u8, data u8{length}

    SPEAKER u8, frequency u16
    --> (status codes)

status codes:
    OK u8
    UNKNOWN_OPCODE u8
    - the opcode is unknown and the connection needs to be reset
    INVALID_OPCODE u8
    - the opcode is known and is decoded properly, but can't be handled
    INVALID_PORT u8
    - port out of range
    - invalid port for stepper motor mode: only even port n is valid, odd port n+1 is affected as well
    INVALID_CONFIG u8
    - POWER(with value!=0)/BRAKE command for stepper motor
    - VELOCITY command for DC motor
    - IO_STATE command for encoder io port
    - motor command for auxiliary stepper motor port
    INVALID_MODE u8
    - mode is not POWER, BRAKE, VELOCITY
    INVALID_FLAGS u8
    - (io_flags & ~0x1F) != 0x00
    - invalid combination: OUTPUT & PULLUP/PULLDOWN; INPUT & ON; PULLUP & PULLDOWN
    INVALID_VALUE u8
    - MOTOR/SERVO value out of range

codes:
    command opcodes:
        VERSION_REQ             0x01
        EMERGENCY_ACTION        0x05
        EMERGENCY_REQ           0x06
        IO_CONFIG               0x10
        ANALOG_REQ              0x20
        IMU_RATE_REQ            0x22
        IMU_ACCEL_REQ           0x23
        IMU_POSE_REQ            0x24
        DIGITAL_REQ             0x30
        MOTOR                   0x40
        MOTOR_POSITIONAL        0x41
        MOTOR_SERVO             0x42
        MOTOR_CONFIG_DC         0x48
        MOTOR_CONFIG_ENCODER    0x49
        MOTOR_CONFIG_STEPPER    0x4A
        SERVO                   0x50
        UART                    0x60
        SPEAKER                 0x70
    reply opcodes:
        VERSION_REP             0x02
        EMERGENCY_REP           0x07
        OK                      0x80
        UNKNOWN_OPCODE          0x81
        INVALID_OPCODE          0x82
        INVALID_PORT            0x83
        INVALID_CONFIG          0x84
        INVALID_MODE            0x85
        INVALID_FLAGS           0x86
        INVALID_VALUE           0x87
        FAIL_EMERG_ACT          0x88
        ANALOG_REP              0xA1
        IMU_RATE_REP            0xA2
        IMU_ACCEL_REP           0xA3
        IMU_POSE_REP            0xA4
        DIGITAL_REP             0xB1
    update opcodes:
{'fraction_non_alphanumeric': 0.055757261410788385, 'fraction_numerical': 0.05355290456431535, 'mean_word_length': 1.6670124481327802, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1840803', 'n_tokens_mistral': 2881, 'n_tokens_neox': 2651, 'n_words': 775}