Michael Walker
/
RPC_RangeFinderDemo
RangeFinder demo code showing the use of RPCFunction
Revision 0:5e8f67a3fc53, committed 2010-09-20
- Comitter:
- MichaelW
- Date:
- Mon Sep 20 14:39:23 2010 +0000
- Child:
- 1:e5e4988258b9
- Commit message:
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RPCInterface.lib Mon Sep 20 14:39:23 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/MichaelW/code/RPCInterface/#9232f9e1178d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SRF08.lib Mon Sep 20 14:39:23 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/chris/code/SRF08/#ba04e9cd48fc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Sep 20 14:39:23 2010 +0000 @@ -0,0 +1,29 @@ +#include "mbed.h" +#include "SerialRPCInterface.h" +#include "SRF08.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() { +//The range finder demo also uses 2 servos but these will be handled entirly over the RPC + + 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()); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Sep 20 14:39:23 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e