Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not handling wrong CRC #6

Open
TK-A369 opened this issue Sep 25, 2021 · 0 comments
Open

Not handling wrong CRC #6

TK-A369 opened this issue Sep 25, 2021 · 0 comments

Comments

@TK-A369
Copy link
Member

TK-A369 commented Sep 25, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant