![](/media/cache/profiles/7c39a5f991bef4a1e34187677a65871d.jpg.50x50_q85.jpg)
Manchester receiver demo.
Dependencies: Manchester mbed CRC16 ManchesterMsg
Diff: main.cpp
- Revision:
- 3:0c6680f77855
- Parent:
- 2:1cb83aa7b99a
- Child:
- 4:649d9a4219c0
--- a/main.cpp Thu May 18 10:50:53 2017 +0000 +++ b/main.cpp Thu May 18 11:07:36 2017 +0000 @@ -7,11 +7,11 @@ int main(void) { Manchester man(p11, p12, 9600); // Tx pin, Rx pin, speed [bps] ManchesterMsg msg(100); // Message container (max bytes) - char str[50]; // Array of char - uint32_t val; - CRC16 crc16; - unsigned short msgCRC16; - unsigned short calcCRC16; + char str[80]; // Storage for the received array of char + uint32_t val; // Storage for the value received + CRC16 crc16; // CRC16 object + unsigned short msgCRC16; // CRC16 received in message + unsigned short calcCRC16; // CRC16 calculated //pc.baud(9600); @@ -29,10 +29,10 @@ } printf("\r\n"); - - calcCRC16 = crc16.calc(msg.data, msg.len - 2); // exclude CRC bytes from calculation + // Calculate CRC16 (CRC bytes are excluded from calculation) + calcCRC16 = crc16.calc(msg.data, msg.len - 2); - // Extract data from message + // Extract data and CRC16 from the message msg >> str >> val >> msgCRC16; printf("msgCRC16 = %d\r\n", msgCRC16);