Browse Source

tfmini: If the distance is 0xFFFF, a negative value is returned

master
murata 3 years ago committed by Daniel Agar
parent
commit
3b277667ff
  1. 6
      src/drivers/distance_sensor/tfmini/tfmini_parser.cpp

6
src/drivers/distance_sensor/tfmini/tfmini_parser.cpp

@ -159,7 +159,11 @@ int tfmini_parse(char c, char *parserbuf, unsigned *parserbuf_index, TFMINI_PARS @@ -159,7 +159,11 @@ int tfmini_parse(char c, char *parserbuf, unsigned *parserbuf_index, TFMINI_PARS
unsigned int t2 = parserbuf[3];
t2 <<= 8;
t2 += t1;
*dist = ((float)t2) / 100;
if (t2 < 0xFFFFu) {
*dist = ((float)t2) / 100;
}
*state = TFMINI_PARSE_STATE::STATE6_GOT_CHECKSUM;
*parserbuf_index = 0;
ret = 0;

Loading…
Cancel
Save