ABELI2019
/
Serial_PC_Protocol
Example Protocol Serial-PC-Communication ToDo: make it better:-)
Revision 0:42484fbe5151, committed 2020-02-03
- Comitter:
- fpucher
- Date:
- Mon Feb 03 10:09:18 2020 +0000
- Commit message:
- RS232 Protocol Serial-PC-Communication
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LM75B.lib Mon Feb 03 10:09:18 2020 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/neilt6/code/LM75B/#7ac462ba84ac
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Feb 03 10:09:18 2020 +0000 @@ -0,0 +1,55 @@ +#include "mbed.h" +#include "LM75B.h" + +#define STR_MAX 10 +DigitalOut led1(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); + +Serial pc(USBTX, USBRX); +LM75B sensor(p28, p27); + +char str[STR_MAX]; +char str2[STR_MAX]; +int index=0; + +int main() +{ + float fwert = 12.23; + char key1[] = "1"; + char key2[] = "2"; + char key3[] = "3"; + char key4[] = "D"; + char keyR[] = "RD"; + char keyW[] = "FWR"; + char keyX[] = "IXX"; + char keyZ[] = "TA"; + sensor.open(); + while (1) { + led1 = !led1; + pc.scanf("%s", str); + if(!strcmp(str, key1)) { + //led1=!led1; + } else if(!strcmp(str, key2)) { + led2=!led2; + } else if(!strcmp(str, key3)) { + led3=!led3; + } else if(!strcmp(str, key4)) { + led4=!led4; + } else if(!strcmp(str, keyR)) { + //led4=1; + snprintf(str2, STR_MAX, "%f", fwert); + pc.printf("%s\n\r", str2); + } else if(!strcmp(str, keyX)) { + //led4=0; + pc.printf("%d\n", 7); + } else if(!strcmp(str, keyW)) { + //led4=0; + pc.printf("%f\n", fwert); + } else if(!strcmp(str, keyZ)) { + //led4=0; + pc.printf("%f\n", (float)sensor); + } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Feb 03 10:09:18 2020 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/252557024ec3 \ No newline at end of file