Skip to content

Commit 78810e4

Browse files
authored
Minimum length increased to avoid reading uninitialised data.
Problems encountered when the getValues packet was reflected back down the serial port and was read as a valid value results packet. The easy solution is to ensure that the values packet is at least 55 bytes long as this is the length of all the data it should contain.
1 parent 1ca18c5 commit 78810e4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

VescUart.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ bool VescUartGetValue(bldcMeasure& values) {
190190
PackSendPayload(command, 1);
191191
delay(100); //needed, otherwise data is not read
192192
int lenPayload = ReceiveUartMessage(payload);
193-
if (lenPayload > 0) {
194-
bool read = ProcessReadPacket(payload, values, lenPayload); //returns true if sucessfull
193+
if (lenPayload > 55) {
194+
bool read = ProcessReadPacket(payload, values, lenPayload); //returns true if sucessful
195195
return read;
196196
}
197197
else

0 commit comments

Comments
 (0)