![](/media/cache/profiles/7c39a5f991bef4a1e34187677a65871d.jpg.50x50_q85.jpg)
Manchester receiver demo.
Dependencies: Manchester mbed CRC16 ManchesterMsg
main.cpp
- Committer:
- hudakz
- Date:
- 2017-05-17
- Revision:
- 1:2ce05484e526
- Parent:
- 0:91017f5f5cb3
- Child:
- 2:1cb83aa7b99a
File content as of revision 1:2ce05484e526:
#include "mbed.h" #include "Manchester.h" DigitalOut led(LED1); 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; //pc.baud(9600); while(1) { if(man.receive(msg)) { // Receive message // Print data length and raw data bytes printf("\r\n----------------------\r\n"); printf("Length = %d\r\n", msg.len); printf("Raw data :\r\n"); for(size_t i = 0; i < msg.len; i++) { if((i + 1) % 10 == 0) printf(" %.2x\r\n", msg.data[i]); else printf(" %.2x", msg.data[i]); } printf("\r\n"); // Extract data from message and print msg >> str >> val; printf("Extracted data :\r\n"); printf(" str = %s\r\n", str); printf(" val = 0x%x\r\n", val); } else printf("Error\r\n"); led = !led; } }