Skip to content

Commit ec2796a

Browse files
committed
Fix: rxHmiData()
1 parent a6c5198 commit ec2796a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

arduino_pico/arduino_pico.ino

+5-3
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@ int rxHmiData(char* dat, int dat_len) {
7272
return 0;
7373
}
7474
int rxlen = Serial1.readBytes(dat, dat_len);
75-
dat[rxlen-1] = 0; // Replace 0x04(EOT) to 0
76-
return rxlen-1;
77-
75+
if(rxlen > 0){
76+
dat[rxlen-1] = 0; // Replace 0x04(EOT) to 0
77+
return rxlen;
78+
}
79+
return 0;
7880
}
7981

8082
// String from BunHMI ptr cmd

0 commit comments

Comments
 (0)