Skip to content

Not handling wrong CRC #6

@TK-A369

Description

@TK-A369

lidar-avr/lidar-avr.c

Lines 107 to 115 in 30be813

if (frame_ready && crc == frame[FRAME_SERVO_LEN - 1]) {
byte_number = 0;
frame_ready = 0;
uint16_t pwm = (frame[4] << 8) + frame[5];
if (pwm >= MIN_DUTY && pwm <= MAX_DUTY) {
OCR1A = pwm; // Set PWM TOP to received PWM duty
}
frame_ready = 0;
}

If CRC is correct, program sets servo and clears frame_ready. And in this case it works.
But if CRC is wrong, program won't enter to if, and frame_ready won't be cleared.
So program can hang when CRC will be wrong. It should be changed. If frame_ready is 1, but CRC is wrong, ignore this frame, and maybe send info about CRC error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions