Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of OS-RPC_Serial by
main.cpp
00001 #include "mbed.h" 00002 #include "SerialRPCInterface.h" 00003 #include "mbed_rpc.h" 00004 00005 Serial pc(USBTX, USBRX); 00006 00007 // Define some Digit outputs to address via Serial 00008 RpcDigitalOut myled1(LED1,"myled1"); 00009 RpcDigitalOut myled2(LED2,"myled2"); 00010 RpcDigitalOut myled3(LED3,"myled3"); 00011 RpcDigitalOut myled4(LED4,"myled4"); 00012 00013 // Define a function to address via Serial 00014 void BCmult(Arguments *input, Reply *output); 00015 RPCFunction rpcScale(&BCmult, "BCmult"); 00016 // This makes x and y global, so they can be changed in BCmult 00017 int x,y; 00018 // Define some variables to address via Serial 00019 RPCVariable<int> rpcLights(&x, "x"); 00020 RPCVariable<int> rpcBanner(&y, "y"); 00021 00022 void BCmult(Arguments *in, Reply *out) { 00023 //int x,y; 00024 char buffer[200]; 00025 x = in->getArg<int>(); 00026 y = in->getArg<int>(); 00027 x = 2*x; 00028 y = 3*y; 00029 sprintf(buffer, "%i, %i\n", x, y ); 00030 out->putData(buffer); 00031 } 00032 int main() { 00033 pc.printf("starting..."); 00034 char buf[256], outbuf[256]; 00035 while(1) { 00036 pc.gets(buf, 256); 00037 RPC::call(buf, outbuf); 00038 // Print the response 00039 pc.printf("%s\n", outbuf); 00040 } 00041 } 00042
Generated on Thu Aug 4 2022 05:25:03 by
1.7.2
