Working with RPC Variables
Dependencies: RPCInterface mbed
Revision 0:85792dec3d95, committed 2016-03-12
- Comitter:
- nambvarun
- Date:
- Sat Mar 12 02:37:08 2016 +0000
- Commit message:
- Example RPC Variables Program;
Changed in this revision
diff -r 000000000000 -r 85792dec3d95 RPCInterface.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RPCInterface.lib Sat Mar 12 02:37:08 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/MichaelW/code/RPCInterface/#bcc2e05e5da4
diff -r 000000000000 -r 85792dec3d95 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Mar 12 02:37:08 2016 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" +#include "mbed_rpc.h" + +// These are examples of some variable types that can be modified through RPC. +int wheelsOn; +char lcdBannerMessage; +float speed; + +RPCVariable<int> rpcLights(&wheelsOn, "wheels"); +RPCVariable<char> rpcBanner(&lcdBannerMessage, "banner"); +RPCVariable<float> rpcSpeed(&speed, "speed"); + +Serial pc(USBTX, USBRX); + +int main() { + //The mbed RPC classes are now wrapped to create an RPC enabled version - see RpcClasses.h so don't add to 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); + } +} \ No newline at end of file
diff -r 000000000000 -r 85792dec3d95 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Mar 12 02:37:08 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/87f2f5183dfb \ No newline at end of file