SG112A: Fix Off By One Error in Read Function
This commit is contained in:
parent
0180a0342f
commit
493a466a90
1 changed files with 4 additions and 7 deletions
|
@ -4,18 +4,15 @@
|
||||||
SG112A::SG112A(void) {
|
SG112A::SG112A(void) {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
Serial.setTimeout(READ_TIMEOUT);
|
Serial.setTimeout(READ_TIMEOUT);
|
||||||
delay(5000);
|
|
||||||
write(CMD_GET_PPM);
|
|
||||||
read();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SG112A::getSensorData(lora_data &loradata) {
|
void SG112A::getSensorData(lora_data &loradata) {
|
||||||
write(CMD_GET_PPM);
|
write(CMD_GET_PPM);
|
||||||
delay(50);
|
delay(50);
|
||||||
uint8_t byteLen = read();
|
uint8_t readBytes = read();
|
||||||
|
|
||||||
if (byteLen > 0) {
|
if (readBytes > 0) {
|
||||||
switch(buffer[3]) {
|
switch(buffer[2]) {
|
||||||
case 0x15:
|
case 0x15:
|
||||||
loradata.ppm = (buffer[5]*256) + buffer[4];
|
loradata.ppm = (buffer[5]*256) + buffer[4];
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue