Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Adafruit_GFX_128x64 DS3231 PinDetect SDFileSystem USBDevice mbed RealtimeMath MODSERIAL
Diff: comms.cpp
- Revision:
- 22:9350752f5414
- Parent:
- 21:2fa676f214fe
- Parent:
- 18:06b718f8e6fd
diff -r 2fa676f214fe -r 9350752f5414 comms.cpp
--- a/comms.cpp Sat Jun 07 07:12:25 2014 +0000
+++ b/comms.cpp Sat Jun 07 07:46:38 2014 +0000
@@ -3,6 +3,7 @@
const int Packet::HEADER_SIZE = 5;
+
/* If successful, loads p with a new packet. User is responsible for deleting.
* Returns > 0 on success
0 on timeout
@@ -21,17 +22,19 @@
PC_PRINTLNF("receivePacket: cmd = %d", cmd);
PC_PRINTLNF("receivePacket: packetNumber = %d", packetNumber);
PC_PRINTLNF("receivePacket: dataLength = %d", dataLength);
-
+
uint8_t data[dataLength];
if (!getBytes(data, dataLength, timeout))
return 0;
PC_PRINTLN("receivePacket: getting checksum");
+
uint16_t checkSum;
if (!getBytes((uint8_t *) &checkSum, sizeof(checkSum), timeout))
return 0;
PC_PRINTLN("receivePacket: verifying checksum");
+
*p = Packet::createAndVerify(cmd, packetNumber, dataLength, data, checkSum);
if (*p == NULL)
return -1;