Skip to content

Commit

Permalink
Merge pull request #4 from pinski1/patch-1
Browse files Browse the repository at this point in the history
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.

Thx to pinski
  • Loading branch information
RollingGecko authored Oct 6, 2016
2 parents 1ca18c5 + 78810e4 commit d76a60c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions VescUart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ bool VescUartGetValue(bldcMeasure& values) {
PackSendPayload(command, 1);
delay(100); //needed, otherwise data is not read
int lenPayload = ReceiveUartMessage(payload);
if (lenPayload > 0) {
bool read = ProcessReadPacket(payload, values, lenPayload); //returns true if sucessfull
if (lenPayload > 55) {
bool read = ProcessReadPacket(payload, values, lenPayload); //returns true if sucessful
return read;
}
else
Expand Down

0 comments on commit d76a60c

Please sign in to comment.