Oscar de Jesus Vasquez
/
RPC_Serial_OVFZ
RPC Serial for Sonar Range Sensor
Fork of RPC_Serial by
main.cpp@2:8c93b51b551f, 2014-07-21 (annotated)
- Committer:
- oscarvzfz
- Date:
- Mon Jul 21 04:17:12 2014 +0000
- Revision:
- 2:8c93b51b551f
- Parent:
- 1:de34af25056a
- Child:
- 3:66aaebc365d3
RPC and SRF05
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MichaelW | 0:78952cd3935b | 1 | #include "mbed.h" |
oscarvzfz | 2:8c93b51b551f | 2 | #include "SRF05.h" |
oscarvzfz | 2:8c93b51b551f | 3 | #include "RPCVariable.h" |
MichaelW | 0:78952cd3935b | 4 | #include "rpc.h" |
oscarvzfz | 2:8c93b51b551f | 5 | |
MichaelW | 0:78952cd3935b | 6 | Serial pc(USBTX, USBRX); |
oscarvzfz | 2:8c93b51b551f | 7 | SRF05 srf(p13, p14); |
oscarvzfz | 2:8c93b51b551f | 8 | float f; |
oscarvzfz | 2:8c93b51b551f | 9 | |
oscarvzfz | 2:8c93b51b551f | 10 | |
MichaelW | 0:78952cd3935b | 11 | int main() { |
MichaelW | 1:de34af25056a | 12 | // setup the classes that can be created dynamically |
MichaelW | 0:78952cd3935b | 13 | Base::add_rpc_class<AnalogIn>(); |
MichaelW | 0:78952cd3935b | 14 | Base::add_rpc_class<AnalogOut>(); |
MichaelW | 0:78952cd3935b | 15 | Base::add_rpc_class<DigitalIn>(); |
MichaelW | 0:78952cd3935b | 16 | Base::add_rpc_class<DigitalOut>(); |
MichaelW | 0:78952cd3935b | 17 | Base::add_rpc_class<DigitalInOut>(); |
MichaelW | 0:78952cd3935b | 18 | Base::add_rpc_class<PwmOut>(); |
MichaelW | 0:78952cd3935b | 19 | Base::add_rpc_class<Timer>(); |
MichaelW | 0:78952cd3935b | 20 | Base::add_rpc_class<SPI>(); |
MichaelW | 0:78952cd3935b | 21 | Base::add_rpc_class<BusOut>(); |
MichaelW | 0:78952cd3935b | 22 | Base::add_rpc_class<BusIn>(); |
MichaelW | 0:78952cd3935b | 23 | Base::add_rpc_class<BusInOut>(); |
MichaelW | 0:78952cd3935b | 24 | Base::add_rpc_class<Serial>(); |
oscarvzfz | 2:8c93b51b551f | 25 | RPCVariable<float> rpc_f(&f, "f"); |
MichaelW | 1:de34af25056a | 26 | // receive commands, and send back the responses |
MichaelW | 0:78952cd3935b | 27 | char buf[256], outbuf[256]; |
MichaelW | 0:78952cd3935b | 28 | while(1) { |
oscarvzfz | 2:8c93b51b551f | 29 | f=srf.read(); |
MichaelW | 0:78952cd3935b | 30 | pc.gets(buf, 256); |
MichaelW | 0:78952cd3935b | 31 | rpc(buf, outbuf); |
MichaelW | 0:78952cd3935b | 32 | pc.printf("%s\n", outbuf); |
MichaelW | 0:78952cd3935b | 33 | } |
MichaelW | 0:78952cd3935b | 34 | } |