Andrew Chen
/
RPC_Serial
serial settings for zumocrawler
Fork of RPC_Serial by
main.cpp@2:188bfc221aad, 2014-06-20 (annotated)
- Committer:
- ajc
- Date:
- Fri Jun 20 20:53:26 2014 +0000
- Revision:
- 2:188bfc221aad
- Parent:
- 1:de34af25056a
mbed rpc for zumocrawler
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MichaelW | 0:78952cd3935b | 1 | #include "mbed.h" |
MichaelW | 0:78952cd3935b | 2 | #include "rpc.h" |
MichaelW | 0:78952cd3935b | 3 | Serial pc(USBTX, USBRX); |
MichaelW | 0:78952cd3935b | 4 | int main() { |
ajc | 2:188bfc221aad | 5 | |
ajc | 2:188bfc221aad | 6 | pc.baud(115200); |
MichaelW | 1:de34af25056a | 7 | // setup the classes that can be created dynamically |
MichaelW | 0:78952cd3935b | 8 | Base::add_rpc_class<AnalogIn>(); |
MichaelW | 0:78952cd3935b | 9 | Base::add_rpc_class<AnalogOut>(); |
MichaelW | 0:78952cd3935b | 10 | Base::add_rpc_class<DigitalIn>(); |
MichaelW | 0:78952cd3935b | 11 | Base::add_rpc_class<DigitalOut>(); |
MichaelW | 0:78952cd3935b | 12 | Base::add_rpc_class<DigitalInOut>(); |
MichaelW | 0:78952cd3935b | 13 | Base::add_rpc_class<PwmOut>(); |
MichaelW | 0:78952cd3935b | 14 | Base::add_rpc_class<Timer>(); |
MichaelW | 0:78952cd3935b | 15 | Base::add_rpc_class<SPI>(); |
MichaelW | 0:78952cd3935b | 16 | Base::add_rpc_class<BusOut>(); |
MichaelW | 0:78952cd3935b | 17 | Base::add_rpc_class<BusIn>(); |
MichaelW | 0:78952cd3935b | 18 | Base::add_rpc_class<BusInOut>(); |
MichaelW | 0:78952cd3935b | 19 | Base::add_rpc_class<Serial>(); |
MichaelW | 1:de34af25056a | 20 | // receive commands, and send back the responses |
MichaelW | 0:78952cd3935b | 21 | char buf[256], outbuf[256]; |
MichaelW | 0:78952cd3935b | 22 | while(1) { |
MichaelW | 0:78952cd3935b | 23 | pc.gets(buf, 256); |
MichaelW | 0:78952cd3935b | 24 | rpc(buf, outbuf); |
MichaelW | 0:78952cd3935b | 25 | pc.printf("%s\n", outbuf); |
MichaelW | 0:78952cd3935b | 26 | } |
MichaelW | 0:78952cd3935b | 27 | } |