RPC over USB serial testing step by step
RPC over usbserial testing with python step by step ( tested on KL25Z on 29 Aug 2013).
1. Get start - mBed firmware installation.
mBed firmware.
http://mbed.org/media/uploads/samux/mbed_if_v2.0_frdm_kl25z.s19
2. Install RPC_USBSerial into KL25Z.
- Register into mbed.org;
- Select platform KL25Z in compiler;
- Import program, Compile, download RPC_USBSerial.bin to PC;
- Save RPC_USBSerial_KL25Z.bin to MBED drive;
3. Install mbed usbserial driver to PC.
- Serial Communication with a PC;
http://mbed.org/handbook/SerialPC;
- Windows serial configuration.
http://mbed.org/handbook/Windows-serial-configuration
Find COM Port name at:
- Control Panel
- > Syetem
- > Hardware
- > Device Manager
- > Ports(COM & LPT)
- > Mbed Virtual Serial Port(COM?) (My one is "COM11" in picture below)
4. Install Python and Pyserial
- install python 2.7
- install pyserial http://sourceforge.net/projects/pyserial/files/pyserial/2.5/pyserial-2.5.win32.exe/download
5. Have fun.
- Modify Port number in serial_raw_rpc_test.py.txt
- Copy/Paste from serial_raw_rpc_test.py.txt to python (command line);
- Copy and run one line at a time to have real fun;
:)
main.cpp
- Committer:
- jooter
- Date:
- 2013-08-29
- Revision:
- 0:b8cfe8c7e985
File content as of revision 0:b8cfe8c7e985:
#include "mbed.h" #include "USBSerial.h" #include "mbed_rpc.h" USBSerial pc; int main() { // setup the classes that can be created dynamically /* RPC::add_rpc_class<RpcAnalogIn>(); RPC::add_rpc_class<RpcAnalogOut>(); */ RPC::add_rpc_class<RpcDigitalIn>(); RPC::add_rpc_class<RpcDigitalOut>(); RPC::add_rpc_class<RpcDigitalInOut>(); RPC::add_rpc_class<RpcPwmOut>(); RPC::add_rpc_class<RpcTimer>(); RPC::add_rpc_class<RpcSPI>(); // RPC::add_rpc_class<RpcBusOut>(); // RPC::add_rpc_class<RpcBusIn>(); // RPC::add_rpc_class<RpcBusInOut>(); RPC::add_rpc_class<RpcSerial>(); // receive commands, and send back the responses char buf[256], outbuf[256]; while(1) { pc.gets(buf, 256); RPC::call(buf, outbuf); pc.printf("%s\n", outbuf); } }