Simple RPC functionality to work with Visual Studio GUI application
Dependencies: 4DGL-uLCD-SE RPCInterface mbed
main.cpp@0:3c342a2555ef, 2018-05-01 (annotated)
- Committer:
- Nydrel
- Date:
- Tue May 01 07:46:31 2018 +0000
- Revision:
- 0:3c342a2555ef
Changed RPCInterface to support RPC arguments of type *char
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Nydrel | 0:3c342a2555ef | 1 | #include "mbed.h" |
Nydrel | 0:3c342a2555ef | 2 | #include "mbed_rpc.h" |
Nydrel | 0:3c342a2555ef | 3 | #include "uLCD_4DGL.h" |
Nydrel | 0:3c342a2555ef | 4 | #include <ctype.h> |
Nydrel | 0:3c342a2555ef | 5 | |
Nydrel | 0:3c342a2555ef | 6 | /** |
Nydrel | 0:3c342a2555ef | 7 | * This example program has been updated to use the RPC implementation in the new mbed libraries. |
Nydrel | 0:3c342a2555ef | 8 | * This example shows the uses of the RPCDigitalOut wrapper class |
Nydrel | 0:3c342a2555ef | 9 | */ |
Nydrel | 0:3c342a2555ef | 10 | |
Nydrel | 0:3c342a2555ef | 11 | //Use the RPC enabled wrapped class - see RpcClasses.h for more info |
Nydrel | 0:3c342a2555ef | 12 | Serial pc(USBTX, USBRX); |
Nydrel | 0:3c342a2555ef | 13 | PinName tx, rx, rst; |
Nydrel | 0:3c342a2555ef | 14 | uLCD_4DGL uLCD(p28, p27, p29); |
Nydrel | 0:3c342a2555ef | 15 | char text; |
Nydrel | 0:3c342a2555ef | 16 | //string screen; |
Nydrel | 0:3c342a2555ef | 17 | |
Nydrel | 0:3c342a2555ef | 18 | void clearLCD(Arguments *in, Reply *out); |
Nydrel | 0:3c342a2555ef | 19 | RPCFunction rpcClear(&clearLCD, "clearLCD"); |
Nydrel | 0:3c342a2555ef | 20 | |
Nydrel | 0:3c342a2555ef | 21 | void printLCD(Arguments *in, Reply *out); |
Nydrel | 0:3c342a2555ef | 22 | RPCFunction rpcPrint(&printLCD, "printLCD"); |
Nydrel | 0:3c342a2555ef | 23 | |
Nydrel | 0:3c342a2555ef | 24 | int main() { |
Nydrel | 0:3c342a2555ef | 25 | |
Nydrel | 0:3c342a2555ef | 26 | char buf[256], outbuf[256]; |
Nydrel | 0:3c342a2555ef | 27 | while(1) { |
Nydrel | 0:3c342a2555ef | 28 | pc.gets(buf, 256); |
Nydrel | 0:3c342a2555ef | 29 | //Call the static call method on the RPC class |
Nydrel | 0:3c342a2555ef | 30 | RPC::call(buf, outbuf); |
Nydrel | 0:3c342a2555ef | 31 | pc.printf("%s\n", outbuf); |
Nydrel | 0:3c342a2555ef | 32 | } |
Nydrel | 0:3c342a2555ef | 33 | } |
Nydrel | 0:3c342a2555ef | 34 | |
Nydrel | 0:3c342a2555ef | 35 | void clearLCD(Arguments *in, Reply *out) |
Nydrel | 0:3c342a2555ef | 36 | { |
Nydrel | 0:3c342a2555ef | 37 | uLCD.cls(); |
Nydrel | 0:3c342a2555ef | 38 | //out->putData("Successfully created uLCD object!"); |
Nydrel | 0:3c342a2555ef | 39 | } |
Nydrel | 0:3c342a2555ef | 40 | |
Nydrel | 0:3c342a2555ef | 41 | void printLCD(Arguments *in, Reply *out) |
Nydrel | 0:3c342a2555ef | 42 | { |
Nydrel | 0:3c342a2555ef | 43 | char * text = in->getArg<char *>(); |
Nydrel | 0:3c342a2555ef | 44 | uLCD.puts(text); |
Nydrel | 0:3c342a2555ef | 45 | uLCD.puts("\n"); |
Nydrel | 0:3c342a2555ef | 46 | } |