RPC over Serial

Dependencies:   mbed-rpc mbed

Committer:
okini3939
Date:
Fri Sep 27 05:26:03 2013 +0000
Revision:
0:7e0e5391432a
Child:
1:ae55f51ee284
1st build

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okini3939 0:7e0e5391432a 1 #include "mbed.h"
okini3939 0:7e0e5391432a 2 #include "mbed_rpc.h"
okini3939 0:7e0e5391432a 3
okini3939 0:7e0e5391432a 4 RPC rpc();
okini3939 0:7e0e5391432a 5 Serial pc(USBTX, USBRX);
okini3939 0:7e0e5391432a 6
okini3939 0:7e0e5391432a 7 int main() {
okini3939 0:7e0e5391432a 8 char buf[256], outbuf[256];
okini3939 0:7e0e5391432a 9
okini3939 0:7e0e5391432a 10 // setup the classes that can be created dynamically
okini3939 0:7e0e5391432a 11 // RPC::add_rpc_class<RpcAnalogIn>();
okini3939 0:7e0e5391432a 12 // RPC::add_rpc_class<RpcAnalogOut>();
okini3939 0:7e0e5391432a 13 RPC::add_rpc_class<RpcDigitalIn>();
okini3939 0:7e0e5391432a 14 RPC::add_rpc_class<RpcDigitalOut>();
okini3939 0:7e0e5391432a 15 RPC::add_rpc_class<RpcDigitalInOut>();
okini3939 0:7e0e5391432a 16 RPC::add_rpc_class<RpcPwmOut>();
okini3939 0:7e0e5391432a 17 RPC::add_rpc_class<RpcTimer>();
okini3939 0:7e0e5391432a 18 RPC::add_rpc_class<RpcSPI>();
okini3939 0:7e0e5391432a 19 RPC::add_rpc_class<RpcSerial>();
okini3939 0:7e0e5391432a 20
okini3939 0:7e0e5391432a 21 // receive commands, and send back the responses
okini3939 0:7e0e5391432a 22 while(1) {
okini3939 0:7e0e5391432a 23 pc.gets(buf, 256);
okini3939 0:7e0e5391432a 24 RPC::call(buf, outbuf);
okini3939 0:7e0e5391432a 25 pc.printf("%s\r\n", outbuf);
okini3939 0:7e0e5391432a 26 }
okini3939 0:7e0e5391432a 27 }