![](/media/cache/profiles/b9f9c5fc82fdcd944d7041adcc98ff36.50x50_q85.png)
Quick Test Hack of the RPCInterface lib - it works for me!!
Dependencies: RPCInterface mbed
Fork of RPC_RangeFinderDemo by
main.cpp
- Committer:
- currystomper
- Date:
- 2012-12-19
- Revision:
- 2:9a7f340bf830
- Parent:
- 1:e5e4988258b9
- Child:
- 3:29986d0e80da
File content as of revision 2:9a7f340bf830:
/** * Copyright (c)2010 ARM Ltd. * Released under the MIT License: http://mbed.org/license/mit */ #include "mbed.h" #include "SerialRPCInterface.h" using namespace mbed; //Create the interface on the USB Serial Port SerialRPCInterface RPC(USBTX, USBRX); void ReadRange(char * input, char * output); RPCFunction RangeFinder(&ReadRange, "RangeFinder"); //SRF08 srf08(p9, p10, 0xE0); // Define SDA, SCL pin and I2C address DigitalOut myled(LED1); int main() { while(1) { myled = 1; wait(0.2); myled = 0; wait(0.2); } } //As neither I2C nor the SRF08 library is avalible directly over RPC we create a Custom Function which we make RPCable by attaching to an RPCFunction void ReadRange(char * input, char * output){ //Format the output of the srf08 into the output string // sprintf(output, "%f", srf08.read()); } /* Code Frags #include "RPCFunction.h" void setTime(char * input, char * output); RPCFunction rpc_setTime(&setTime, "setTime"); void setTime(char * input, char * output){ int hours,mins,secs; sscanf(input, "%i,%i,%i", &hours, &mins, &secs); //Use the hours, mins, secs variables to set the time here sprintf(ouput, "Anything you want to output here - you don't really need it"); */