David Cabinian / Mbed 2 deprecated RPC_ObjectInstantiation

Dependencies:   mbed-rpc mbed

Fork of RPC_DigitalInDigitalOutPWMOutoverSerial by David Cabinian

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "mbed_rpc.h"
00003 
00004 /**
00005  *  This example program has been updated to use the RPC implementation in the new mbed libraries.
00006  *  This example shows the creation of the RPCDigitalOut wrapper class over the RPC interface
00007  */
00008 
00009 //Use the RPC enabled wrapped class  - see RpcClasses.h for more info
00010 RpcDigitalOut led1(LED1,"led1");
00011 Serial pc(USBTX, USBRX);
00012 
00013 int main() {
00014     //Allows RPC to create objects of type RPCDigitalOut via the RPC Interface
00015     RPC::add_rpc_class<RpcDigitalOut>();
00016 
00017     char buf[256], outbuf[256];
00018     while(1) {
00019         pc.gets(buf, 256);
00020         //Call the static call method on the RPC class
00021         RPC::call(buf, outbuf); 
00022         pc.printf("%s\n", outbuf);
00023     }
00024 }