|
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.
lidar-avr/lidar-avr.c
Lines 107 to 115 in 30be813
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, andframe_readywon't be cleared.So program can hang when CRC will be wrong. It should be changed. If
frame_readyis 1, but CRC is wrong, ignore this frame, and maybe send info about CRC error.