David Cabinian
/
RPC_DigitalInDigitalOutPWMOutoverSerial
A RPC example usage program.
Fork of RPC_Serial by
main.cpp@3:4ddd10908e46, 2014-08-14 (annotated)
- Committer:
- MichaelW
- Date:
- Thu Aug 14 09:25:00 2014 +0000
- Revision:
- 3:4ddd10908e46
- Parent:
- 2:37712731e13d
- Child:
- 4:d69dfbef9644
Updated comments;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MichaelW | 0:78952cd3935b | 1 | #include "mbed.h" |
MichaelW | 2:37712731e13d | 2 | #include "mbed_rpc.h" |
MichaelW | 2:37712731e13d | 3 | |
MichaelW | 3:4ddd10908e46 | 4 | /** |
MichaelW | 3:4ddd10908e46 | 5 | * This example program has been updated to use the RPC implementation in the new mbed libraries. |
MichaelW | 3:4ddd10908e46 | 6 | * This example demonstrates using RPC over serial |
MichaelW | 3:4ddd10908e46 | 7 | */ |
MichaelW | 2:37712731e13d | 8 | |
MichaelW | 2:37712731e13d | 9 | //Use the RPC enabled wrapped class - see RpcClasses.h for more info |
MichaelW | 2:37712731e13d | 10 | RpcDigitalOut myled(LED4,"myled"); |
MichaelW | 2:37712731e13d | 11 | |
MichaelW | 0:78952cd3935b | 12 | Serial pc(USBTX, USBRX); |
MichaelW | 0:78952cd3935b | 13 | int main() { |
MichaelW | 3:4ddd10908e46 | 14 | //The mbed RPC classes are now wrapped to create an RPC enabled version - see RpcClasses.h so don't add to base class |
MichaelW | 2:37712731e13d | 15 | |
MichaelW | 1:de34af25056a | 16 | // receive commands, and send back the responses |
MichaelW | 0:78952cd3935b | 17 | char buf[256], outbuf[256]; |
MichaelW | 0:78952cd3935b | 18 | while(1) { |
MichaelW | 0:78952cd3935b | 19 | pc.gets(buf, 256); |
MichaelW | 2:37712731e13d | 20 | //Call the static call method on the RPC class |
MichaelW | 2:37712731e13d | 21 | RPC::call(buf, outbuf); |
MichaelW | 0:78952cd3935b | 22 | pc.printf("%s\n", outbuf); |
MichaelW | 0:78952cd3935b | 23 | } |
MichaelW | 0:78952cd3935b | 24 | } |