WWW serwer SKM
Dependencies: SDFileSystem mbed
Fork of SKM_SERWER_WWW by
main.cpp
- Committer:
- erigow01
- Date:
- 2015-02-23
- Revision:
- 1:623f51ea713b
- Parent:
- 0:f682dcf80f00
- Child:
- 2:8d5a84fcf90c
File content as of revision 1:623f51ea713b:
#include "mbed.h" //Simple program allowing user to send messages from mbed COM out through UART to another UART COM. //Andrea Corrado //Updated 2015/02/23 Eric Gowland - Process on line termination. Serial pc(USBTX, USBRX); // tx, rx Serial uart (PTC17, PTC16); char* PARSE_TRIGGERS = "\r\n"; int PARSE_TRIGGERS_LENGTH = 2; int MAX_BUFFER_SIZE = 128; bool isTriggerChar(char c); int main() { char buffer[MAX_BUFFER_SIZE]; int pos = 0; char thisChar = 0; while(1) { if (pc.readable()) { thisChar = pc.getc(); //Echo pc.putc(thisChar); //Buffer buffer[pos++] = thisChar; //If trigger or buffer overflow, output and reset buffer... if(pos >= MAX_BUFFER_SIZE || isTriggerChar(thisChar)) { pc.printf("\r\n"); uart.printf("%.*s\r\n", pos, buffer); pos = 0; } } } } bool isTriggerChar(char c) { for (int i = 0; i < PARSE_TRIGGERS_LENGTH; i++) { if(c == PARSE_TRIGGERS[i]) { return true; } } return false; }