A RPC example usage program.

Dependencies:   mbed-rpc mbed

Fork of RPC_Serial by Michael Walker

Committer:
dhcabinian
Date:
Sat Mar 12 02:30:33 2016 +0000
Revision:
4:d69dfbef9644
Parent:
3:4ddd10908e46
Child:
5:59421f613a13
RPC example of Digital In, Digital Out, and PWM Out over serial.

Who changed what in which revision?

UserRevisionLine numberNew 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.
dhcabinian 4:d69dfbef9644 6 * This example demonstrates using RPC over serial with DigitalOut, DigitalIn, and PWMOut usages
MichaelW 3:4ddd10908e46 7 */
MichaelW 2:37712731e13d 8
MichaelW 2:37712731e13d 9 //Use the RPC enabled wrapped class - see RpcClasses.h for more info
dhcabinian 4:d69dfbef9644 10 RpcDigitalOut myled(LED4,"mbedled");
dhcabinian 4:d69dfbef9644 11 RpcDigitalIn swIn(p8, "switchIn");
dhcabinian 4:d69dfbef9644 12 RpcPwmOut led(p21, "pwmled");
MichaelW 2:37712731e13d 13
MichaelW 0:78952cd3935b 14 Serial pc(USBTX, USBRX);
MichaelW 0:78952cd3935b 15 int main() {
MichaelW 3:4ddd10908e46 16 //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 17
MichaelW 1:de34af25056a 18 // receive commands, and send back the responses
MichaelW 0:78952cd3935b 19 char buf[256], outbuf[256];
MichaelW 0:78952cd3935b 20 while(1) {
MichaelW 0:78952cd3935b 21 pc.gets(buf, 256);
MichaelW 2:37712731e13d 22 //Call the static call method on the RPC class
MichaelW 2:37712731e13d 23 RPC::call(buf, outbuf);
MichaelW 0:78952cd3935b 24 pc.printf("%s\n", outbuf);
MichaelW 0:78952cd3935b 25 }
dhcabinian 4:d69dfbef9644 26 }