Search Code
About RPC_Serial

First published 24 Aug 2010, with 2 revisions since.
Last update: 24 Aug 2010.
View history

Last change message: N/A

Related to

Import this program

RPC_Serial

Published 24 Aug 2010, by   user Michael Walker   tag No tags
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "rpc.h"
00003 Serial pc(USBTX, USBRX);
00004 int main() {
00005     // setup the classes that can be created dynamically
00006     Base::add_rpc_class<AnalogIn>();
00007     Base::add_rpc_class<AnalogOut>();
00008     Base::add_rpc_class<DigitalIn>();
00009     Base::add_rpc_class<DigitalOut>();
00010     Base::add_rpc_class<DigitalInOut>();
00011     Base::add_rpc_class<PwmOut>();
00012     Base::add_rpc_class<Timer>();
00013     Base::add_rpc_class<SPI>();
00014     Base::add_rpc_class<BusOut>();
00015     Base::add_rpc_class<BusIn>();
00016     Base::add_rpc_class<BusInOut>();
00017     Base::add_rpc_class<Serial>();
00018     // receive commands, and send back the responses
00019     char buf[256], outbuf[256];
00020     while(1) {
00021         pc.gets(buf, 256);
00022         rpc(buf, outbuf); 
00023         pc.printf("%s\n", outbuf);
00024     }
00025 }