Alberto Piganti
/
blip_serial
miniBLIP usb serial hello world
Fork of USBSerial_HelloWorld by
main.cpp@11:4d863ea0d088, 2015-12-04 (annotated)
- Committer:
- pighixxx
- Date:
- Fri Dec 04 16:03:23 2015 +0000
- Revision:
- 11:4d863ea0d088
- Parent:
- 10:dc64a826c87b
added scanf example
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
samux | 7:5e693654d5b4 | 1 | #include "mbed.h" |
samux | 7:5e693654d5b4 | 2 | #include "USBSerial.h" |
samux | 7:5e693654d5b4 | 3 | |
samux | 7:5e693654d5b4 | 4 | //Virtual serial port over USB |
samux | 7:5e693654d5b4 | 5 | USBSerial serial; |
samux | 7:5e693654d5b4 | 6 | |
samux | 7:5e693654d5b4 | 7 | int main(void) { |
pighixxx | 11:4d863ea0d088 | 8 | char buffer[128]; // Max char in buffer |
pighixxx | 10:dc64a826c87b | 9 | serial.printf("miniBlip\r\n"); |
samux | 7:5e693654d5b4 | 10 | while(1) |
samux | 7:5e693654d5b4 | 11 | { |
pighixxx | 11:4d863ea0d088 | 12 | serial.scanf("%s\n", &buffer); |
pighixxx | 11:4d863ea0d088 | 13 | serial.printf("Received: '%s'\n", buffer); |
pighixxx | 11:4d863ea0d088 | 14 | if(strcmp(buffer,"miniBLIP")==0) { |
pighixxx | 11:4d863ea0d088 | 15 | // Do something |
pighixxx | 11:4d863ea0d088 | 16 | } |
samux | 9:d88699a0905a | 17 | wait(1); |
samux | 7:5e693654d5b4 | 18 | } |
pighixxx | 11:4d863ea0d088 | 19 | } |