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: ConfigFile EthernetInterface mbed-rtos mbed
Fork of S05APP3 by
Diff: main.cpp
- Revision:
- 7:ea6d3c6ac200
- Parent:
- 6:fd7d91edcf60
- Child:
- 8:9c34eb3cb3ef
diff -r fd7d91edcf60 -r ea6d3c6ac200 main.cpp --- a/main.cpp Sun Feb 12 02:27:01 2017 +0000 +++ b/main.cpp Sun Feb 12 03:59:00 2017 +0000 @@ -15,15 +15,12 @@ bool boolLED = false; void printBuffer(uint8_t bufferSize, uint8_t* buffer) { - for(int k = 0; k < bufferSize; k++) { + for(int k = 0; k <= bufferSize; k++) { pc.printf("%X-", buffer[k]); } printf("\n"); } -/* -* Read a configuration file from a mbed. -*/ void readConfigFile() { LocalFileSystem local("local"); ConfigFile cfg; @@ -114,7 +111,7 @@ } } -void verifyChecksum(uint16_t frameSize, uint8_t* buffer) { +void checksum(uint16_t frameSize, uint8_t* buffer) { uint32_t checkSum = 0; for (int i = 0; i < frameSize; i++) { @@ -123,33 +120,30 @@ if ((0xFF - (checkSum & 0xFF)) != buffer[frameSize]) { pc.printf("Erreur dans le checksum. \n"); } - - checkForError(buffer); + + //checkForError(buffer); } void readFrame(){ uint8_t sizeBytes[2] = { 0 }; uint8_t buffer[104] = { 0 }; - - while (xbee.readable() == 0){} // Wait for UART to have new data - pc.printf("new char"); - + if (xbee.readable() && xbee.getc() == 0x7E) { for (int i = 0; i < 2;) { sizeBytes[i] = xbee.getc(); i++; } - uint16_t frameSize = getFrameSize(sizeBytes[0], sizeBytes[1]); + uint16_t bufferSize = getFrameSize(sizeBytes[0], sizeBytes[1]); - for (int j = 0; j <= frameSize;) { + for (int j = 0; j <= bufferSize;) { if (xbee.readable()) { buffer[j] = xbee.getc(); j++; } } - verifyChecksum(frameSize, buffer); - printBuffer(frameSize, buffer); + checksum(bufferSize, buffer); + printBuffer(bufferSize, buffer); } }