![](/media/cache/profiles/b9f9c5fc82fdcd944d7041adcc98ff36.50x50_q85.png)
Quick Test Hack of the RPCInterface lib - it works for me!!
Dependencies: RPCInterface mbed
Fork of RPC_RangeFinderDemo by
main.cpp@4:7cc27231579b, 2012-12-20 (annotated)
- Committer:
- currystomper
- Date:
- Thu Dec 20 09:05:23 2012 +0000
- Revision:
- 4:7cc27231579b
- Parent:
- 3:29986d0e80da
Line feed added to print statement and comment on what to type on terminal
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MichaelW | 1:e5e4988258b9 | 1 | /** |
MichaelW | 1:e5e4988258b9 | 2 | * Copyright (c)2010 ARM Ltd. |
MichaelW | 1:e5e4988258b9 | 3 | * Released under the MIT License: http://mbed.org/license/mit |
MichaelW | 1:e5e4988258b9 | 4 | */ |
MichaelW | 0:5e8f67a3fc53 | 5 | #include "mbed.h" |
MichaelW | 0:5e8f67a3fc53 | 6 | #include "SerialRPCInterface.h" |
currystomper | 2:9a7f340bf830 | 7 | |
MichaelW | 0:5e8f67a3fc53 | 8 | |
MichaelW | 0:5e8f67a3fc53 | 9 | using namespace mbed; |
MichaelW | 0:5e8f67a3fc53 | 10 | |
MichaelW | 0:5e8f67a3fc53 | 11 | //Create the interface on the USB Serial Port |
currystomper | 3:29986d0e80da | 12 | SerialRPCInterface RPC(USBTX, USBRX, 9600); // it defaults to 9600 if you don't put the baud Paramete in but I've put it in so can be changed |
currystomper | 3:29986d0e80da | 13 | void SetTime(char * input, char * output); |
currystomper | 3:29986d0e80da | 14 | RPCFunction TimeSet(&SetTime, "TimeSet"); |
MichaelW | 0:5e8f67a3fc53 | 15 | DigitalOut myled(LED1); |
MichaelW | 0:5e8f67a3fc53 | 16 | |
MichaelW | 0:5e8f67a3fc53 | 17 | int main() { |
MichaelW | 0:5e8f67a3fc53 | 18 | |
currystomper | 3:29986d0e80da | 19 | while(1) { |
MichaelW | 0:5e8f67a3fc53 | 20 | myled = 1; |
MichaelW | 0:5e8f67a3fc53 | 21 | wait(0.2); |
MichaelW | 0:5e8f67a3fc53 | 22 | myled = 0; |
MichaelW | 0:5e8f67a3fc53 | 23 | wait(0.2); |
MichaelW | 0:5e8f67a3fc53 | 24 | } |
MichaelW | 0:5e8f67a3fc53 | 25 | } |
MichaelW | 0:5e8f67a3fc53 | 26 | |
currystomper | 3:29986d0e80da | 27 | // REM to call this function via RPC TimeSet |
currystomper | 3:29986d0e80da | 28 | void SetTime(char * input, char * output){ |
currystomper | 3:29986d0e80da | 29 | time_t time_value = time_t(input); |
currystomper | 3:29986d0e80da | 30 | set_time(time_value); |
currystomper | 3:29986d0e80da | 31 | time_t seconds = time(NULL); |
currystomper | 4:7cc27231579b | 32 | sprintf(output, "\r\n Time as seconds since January 1, 1970 = %d\r\n", seconds); // puts String into "output" for SerialRPC to process and transmit |
MichaelW | 0:5e8f67a3fc53 | 33 | } |
currystomper | 2:9a7f340bf830 | 34 | |
currystomper | 4:7cc27231579b | 35 | // so set up terminal up to 9600 baud and type "/TimeSet/run 232323" |
currystomper | 3:29986d0e80da | 36 |