Fork of mbed RPC_serial to fix build errors. mbed RPC_Serial for LabVIEW interface: http://mbed.org/cookbook/Interfacing-with-LabVIEW http://mbed.org/cookbook/Interfacing-Using-RPC Steps: *Compile RPC_Serial main *Copy bit file to mbed flash and reset *Run examples in LabVIEW
Fork of RPC_Serial by
main.cpp@2:fe5692354530, 2015-04-24 (annotated)
- Committer:
- apullin
- Date:
- Fri Apr 24 03:20:22 2015 +0000
- Revision:
- 2:fe5692354530
- Parent:
- 1:c7b247964631
Changed ifdef's to if's, since library does define 1/0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
harrisjunaid | 0:3ffd66df9efb | 1 | #include "mbed.h" |
apullin | 2:fe5692354530 | 2 | #include "mbed_rpc.h" |
apullin | 2:fe5692354530 | 3 | |
apullin | 2:fe5692354530 | 4 | //using namespace mbed; |
apullin | 1:c7b247964631 | 5 | |
harrisjunaid | 0:3ffd66df9efb | 6 | Serial pc(USBTX, USBRX); |
apullin | 1:c7b247964631 | 7 | |
harrisjunaid | 0:3ffd66df9efb | 8 | int main() { |
harrisjunaid | 0:3ffd66df9efb | 9 | // setup the classes that can be created dynamically |
apullin | 2:fe5692354530 | 10 | |
apullin | 2:fe5692354530 | 11 | //These exist for all platforms |
apullin | 2:fe5692354530 | 12 | RPC::add_rpc_class<RpcDigitalIn>(); |
apullin | 2:fe5692354530 | 13 | RPC::add_rpc_class<RpcDigitalOut>(); |
apullin | 2:fe5692354530 | 14 | RPC::add_rpc_class<RpcDigitalInOut>(); |
apullin | 2:fe5692354530 | 15 | RPC::add_rpc_class<RpcTimer>(); |
apullin | 2:fe5692354530 | 16 | |
apullin | 2:fe5692354530 | 17 | //Others are conditional by platform |
apullin | 2:fe5692354530 | 18 | |
apullin | 2:fe5692354530 | 19 | //Unknown how RPC would work if serial was not present? |
apullin | 2:fe5692354530 | 20 | #if DEVICE_SERIAL |
apullin | 2:fe5692354530 | 21 | RPC::add_rpc_class<RpcSerial>(); |
apullin | 2:fe5692354530 | 22 | #else |
apullin | 2:fe5692354530 | 23 | #warning "No Serial function available in this configuration." |
apullin | 2:fe5692354530 | 24 | #endif |
apullin | 2:fe5692354530 | 25 | |
apullin | 2:fe5692354530 | 26 | #if DEVICE_ANALOGIN |
apullin | 2:fe5692354530 | 27 | RPC::add_rpc_class<RpcAnalogIn>(); |
apullin | 2:fe5692354530 | 28 | #else |
apullin | 2:fe5692354530 | 29 | #warning "No AnalogIn function available in this configuration." |
apullin | 2:fe5692354530 | 30 | #endif |
apullin | 2:fe5692354530 | 31 | |
apullin | 2:fe5692354530 | 32 | #if DEVICE_ANALOGOUT |
apullin | 2:fe5692354530 | 33 | RPC::add_rpc_class<RpcAnalogOut>(); |
apullin | 2:fe5692354530 | 34 | #else |
apullin | 2:fe5692354530 | 35 | #warning "No AnalogOut function available in this configuration." |
apullin | 2:fe5692354530 | 36 | #endif |
apullin | 2:fe5692354530 | 37 | |
apullin | 2:fe5692354530 | 38 | #if DEVICE_PWMOUT |
apullin | 2:fe5692354530 | 39 | RPC::add_rpc_class<RpcPwmOut>(); |
apullin | 2:fe5692354530 | 40 | #else |
apullin | 2:fe5692354530 | 41 | #warning "No PWMOut function available in this configuration." |
apullin | 2:fe5692354530 | 42 | #endif |
apullin | 2:fe5692354530 | 43 | |
apullin | 2:fe5692354530 | 44 | #if DEVICE_SPI |
apullin | 2:fe5692354530 | 45 | RPC::add_rpc_class<RpcSPI>(); |
apullin | 2:fe5692354530 | 46 | #else |
apullin | 2:fe5692354530 | 47 | #warning "No SPI function available in this configuration." |
apullin | 2:fe5692354530 | 48 | #endif |
apullin | 2:fe5692354530 | 49 | |
apullin | 2:fe5692354530 | 50 | //These appear to not be implemented |
apullin | 2:fe5692354530 | 51 | //RPC::add_rpc_class<BusOut>(); |
apullin | 2:fe5692354530 | 52 | //RPC::add_rpc_class<RpcBusIn>(); |
apullin | 2:fe5692354530 | 53 | //RPC::add_rpc_class<RpcBusInOut>(); |
apullin | 2:fe5692354530 | 54 | |
harrisjunaid | 0:3ffd66df9efb | 55 | // receive commands, and send back the responses |
apullin | 2:fe5692354530 | 56 | char buf[RPC_MAX_STRING], outbuf[RPC_MAX_STRING]; |
harrisjunaid | 0:3ffd66df9efb | 57 | while(1) { |
apullin | 2:fe5692354530 | 58 | pc.gets(buf, RPC_MAX_STRING); |
apullin | 2:fe5692354530 | 59 | RPC::call(buf, outbuf); |
harrisjunaid | 0:3ffd66df9efb | 60 | pc.printf("%s\n", outbuf); |
harrisjunaid | 0:3ffd66df9efb | 61 | } |
apullin | 2:fe5692354530 | 62 | |
harrisjunaid | 0:3ffd66df9efb | 63 | } |