RPC Serial for Sonar Range Sensor

Dependencies:   mbed-rpc mbed

Fork of RPC_Serial by Michael Walker

main.cpp

Committer:
MichaelW
Date:
2014-08-14
Revision:
4:37712731e13d
Parent:
1:de34af25056a
Child:
5:4ddd10908e46

File content as of revision 4:37712731e13d:

#include "mbed.h"
#include "mbed_rpc.h"

//This example program as been updated to use the RPC implementation in the new mbed libraries.

//Use the RPC enabled wrapped class  - see RpcClasses.h for more info
RpcDigitalOut myled(LED4,"myled");

Serial pc(USBTX, USBRX);
int main() {
    //The mbed RPC classes are now wrapped to create an RPC enabled version - see RpcClasses.h so no longer any need to add them to the base class
    
    // receive commands, and send back the responses
    char buf[256], outbuf[256];
    while(1) {
        pc.gets(buf, 256);
        //Call the static call method on the RPC class
        RPC::call(buf, outbuf); 
        pc.printf("%s\n", outbuf);
    }
}