RPC Serial for Sonar Range Sensor

Dependencies:   mbed-rpc mbed

Fork of RPC_Serial by Michael Walker

main.cpp

Committer:
oscarvzfz
Date:
2014-07-21
Revision:
2:8c93b51b551f
Parent:
1:de34af25056a
Child:
3:66aaebc365d3

File content as of revision 2:8c93b51b551f:

#include "mbed.h"
#include "SRF05.h"
#include "RPCVariable.h"
#include "rpc.h"

Serial pc(USBTX, USBRX);
SRF05 srf(p13, p14);
float f;


int main() {
    // setup the classes that can be created dynamically
    Base::add_rpc_class<AnalogIn>();
    Base::add_rpc_class<AnalogOut>();
    Base::add_rpc_class<DigitalIn>();
    Base::add_rpc_class<DigitalOut>();
    Base::add_rpc_class<DigitalInOut>();
    Base::add_rpc_class<PwmOut>();
    Base::add_rpc_class<Timer>();
    Base::add_rpc_class<SPI>();
    Base::add_rpc_class<BusOut>();
    Base::add_rpc_class<BusIn>();
    Base::add_rpc_class<BusInOut>();
    Base::add_rpc_class<Serial>();
    RPCVariable<float> rpc_f(&f, "f");
    // receive commands, and send back the responses
    char buf[256], outbuf[256];
    while(1) {
        f=srf.read();
        pc.gets(buf, 256);
        rpc(buf, outbuf); 
        pc.printf("%s\n", outbuf);
    }
}