Quick Test Hack of the RPCInterface lib - it works for me!!

Dependencies:   RPCInterface mbed

Fork of RPC_RangeFinderDemo by Michael Walker

Committer:
currystomper
Date:
Wed Dec 19 10:44:10 2012 +0000
Revision:
2:9a7f340bf830
Parent:
1:e5e4988258b9
Child:
3:29986d0e80da
Hack of RangeFinder program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MichaelW 1:e5e4988258b9 1 /**
MichaelW 1:e5e4988258b9 2 * Copyright (c)2010 ARM Ltd.
MichaelW 1:e5e4988258b9 3 * Released under the MIT License: http://mbed.org/license/mit
MichaelW 1:e5e4988258b9 4 */
MichaelW 0:5e8f67a3fc53 5 #include "mbed.h"
MichaelW 0:5e8f67a3fc53 6 #include "SerialRPCInterface.h"
currystomper 2:9a7f340bf830 7
MichaelW 0:5e8f67a3fc53 8
MichaelW 0:5e8f67a3fc53 9 using namespace mbed;
MichaelW 0:5e8f67a3fc53 10
MichaelW 0:5e8f67a3fc53 11 //Create the interface on the USB Serial Port
MichaelW 0:5e8f67a3fc53 12 SerialRPCInterface RPC(USBTX, USBRX);
MichaelW 0:5e8f67a3fc53 13 void ReadRange(char * input, char * output);
MichaelW 0:5e8f67a3fc53 14 RPCFunction RangeFinder(&ReadRange, "RangeFinder");
currystomper 2:9a7f340bf830 15 //SRF08 srf08(p9, p10, 0xE0); // Define SDA, SCL pin and I2C address
MichaelW 0:5e8f67a3fc53 16 DigitalOut myled(LED1);
MichaelW 0:5e8f67a3fc53 17
MichaelW 0:5e8f67a3fc53 18 int main() {
MichaelW 0:5e8f67a3fc53 19
MichaelW 0:5e8f67a3fc53 20 while(1) {
MichaelW 1:e5e4988258b9 21
MichaelW 1:e5e4988258b9 22
MichaelW 0:5e8f67a3fc53 23 myled = 1;
MichaelW 0:5e8f67a3fc53 24 wait(0.2);
MichaelW 0:5e8f67a3fc53 25 myled = 0;
MichaelW 0:5e8f67a3fc53 26 wait(0.2);
MichaelW 0:5e8f67a3fc53 27 }
MichaelW 0:5e8f67a3fc53 28 }
MichaelW 0:5e8f67a3fc53 29
MichaelW 0:5e8f67a3fc53 30 //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
MichaelW 0:5e8f67a3fc53 31 void ReadRange(char * input, char * output){
MichaelW 0:5e8f67a3fc53 32 //Format the output of the srf08 into the output string
currystomper 2:9a7f340bf830 33 // sprintf(output, "%f", srf08.read());
MichaelW 0:5e8f67a3fc53 34 }
currystomper 2:9a7f340bf830 35
currystomper 2:9a7f340bf830 36
currystomper 2:9a7f340bf830 37 /* Code Frags
currystomper 2:9a7f340bf830 38 #include "RPCFunction.h"
currystomper 2:9a7f340bf830 39 void setTime(char * input, char * output);
currystomper 2:9a7f340bf830 40 RPCFunction rpc_setTime(&setTime, "setTime");
currystomper 2:9a7f340bf830 41
currystomper 2:9a7f340bf830 42 void setTime(char * input, char * output){
currystomper 2:9a7f340bf830 43 int hours,mins,secs;
currystomper 2:9a7f340bf830 44 sscanf(input, "%i,%i,%i", &hours, &mins, &secs);
currystomper 2:9a7f340bf830 45
currystomper 2:9a7f340bf830 46 //Use the hours, mins, secs variables to set the time here
currystomper 2:9a7f340bf830 47
currystomper 2:9a7f340bf830 48 sprintf(ouput, "Anything you want to output here - you don't really need it");
currystomper 2:9a7f340bf830 49
currystomper 2:9a7f340bf830 50 */