RPC Serial for Sonar Range Sensor

Dependencies:   mbed-rpc mbed

Fork of RPC_Serial by Michael Walker

Committer:
MichaelW
Date:
Thu Aug 14 09:25:00 2014 +0000
Revision:
5:4ddd10908e46
Parent:
4:37712731e13d
Updated comments;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MichaelW 0:78952cd3935b 1 #include "mbed.h"
MichaelW 4:37712731e13d 2 #include "mbed_rpc.h"
MichaelW 4:37712731e13d 3
MichaelW 5:4ddd10908e46 4 /**
MichaelW 5:4ddd10908e46 5 * This example program has been updated to use the RPC implementation in the new mbed libraries.
MichaelW 5:4ddd10908e46 6 * This example demonstrates using RPC over serial
MichaelW 5:4ddd10908e46 7 */
MichaelW 4:37712731e13d 8
MichaelW 4:37712731e13d 9 //Use the RPC enabled wrapped class - see RpcClasses.h for more info
MichaelW 4:37712731e13d 10 RpcDigitalOut myled(LED4,"myled");
MichaelW 4:37712731e13d 11
MichaelW 0:78952cd3935b 12 Serial pc(USBTX, USBRX);
MichaelW 0:78952cd3935b 13 int main() {
MichaelW 5: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 4: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 4:37712731e13d 20 //Call the static call method on the RPC class
MichaelW 4:37712731e13d 21 RPC::call(buf, outbuf);
MichaelW 0:78952cd3935b 22 pc.printf("%s\n", outbuf);
MichaelW 0:78952cd3935b 23 }
MichaelW 0:78952cd3935b 24 }