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.
Diff: DO/DO.cpp
- Revision:
- 0:703249a56b9d
- Child:
- 1:5c0ca9bdf810
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DO/DO.cpp Mon Oct 23 13:13:33 2017 +0000 @@ -0,0 +1,32 @@ +#include "mbed.h" +#include "DO.h" +#include "config.h" + + +char calcCRC16(char* trame) +{ + char length = trame[2]; + int CRC16 = 0xFFFF; + for(char i =0x00; i<length; i++) { + CRC16 = CRC16 ^ trame[3+i]; + for(int j = 0 ; j<8 ; j++) { + if((CRC16 & 0x1)==0x01) { + CRC16 = CRC16/2 ^ 0xA001; + } else { + CRC16 = CRC16/2; + } + } + } + return CRC16 & 0x00FF ; +} + + +void recieveData(char* data){ + if(calcCRC16(data)){ + + } + else{ + printf("Erreur : Checksum incorect \n"); + } + +}