example serial interface for python and LPC11U24

Dependencies:   mbed-rpc mbed

Fork of RPC_Serial by Michael Walker

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