2014年7月2日 星期三

Modbus/TCP in Android with Python, using modbus_tk

in last case, we use a TCP socket to send Modbus/TCP commnad
and then print out the result to test Modbus/TCP in android

now, we will use a good library for Modbus ==> modbus_tk
you may can find three modbus solutions:
1. pymodbus: it's a good library for python with huge structure...
  it support Modbus/RTU and Modbus/TCP, but I don't use it here.
  because it always need pySerial library. If you can't put the pySerial library into your system, the pymodbus don't work...

2. MinimalModbus: a minimal modbus library. it just support Modbus/RTU.

3. modbus_tk: it's a nice modbus library!! it support Modbus/RTU and Modbus/TCP
  if you don't use Modbus/RTU, you have no need to install pySerial library! (good!)

so finally, I choose modbus_tk to develop modbus program

the step to demonstrate:
1. download modbus-tk here, and then unzip modbus-tk-0.4.2.zip into modbus_tk folder.
2. download mbTcpTest2.py here.
3. the screenshot as below:
in modbus_tk
4. put all the file into your android phone with SL4A, and the execute it!!

enjoy it!!~~





沒有留言:

張貼留言