Modbus over RS232 for Android
Hi, I have been working on a project where I need to connect a Android phone to ABB industrial drive. I'm developing an app which connects to the drive via FTDI module (usb to rs232) http://goo.gl/sjSzYO To get serial communication on an Android device I use usb-serial-for-android library from http://goo.gl/1QaQPn
What I achieved so far:
I have a terminal app http://goo.gl/Wf14Di where I've got communications established by tapping on click (btConnectClick). It detects FTDI chip and selects correct driver. When it all done it runs a listener (SerialInputOutputManager.Listener) and updates method updateReceivedData(data) on received data.
To test it I tap on Send button where it sends in hex (converted to bytes) a request (string). String has an address x01, request to read Holding Register x03, starts from address 100 (x63) and x07 of them with CRC x45 xD7. The request looks as the following 01030064000745D7.
And I get a response 01030E000000000000000000000000012D2E98 which is expected and absolutely correct. I have all zeros and last number is 301 Volt.
What is a question:
How I can use (or modify) Modbus4j library to match the current serial library InputStream and OutputStream. I have tried to use Transport class with my InputStream and it didn't work. As far as I understand from the Modbus4j test (in library) I have to create a ModbusFactory instance, set serial parameters, create a ModbusMaster and use ModbusLocator to get values. However I don't understand how to implement the android serial Input/OutputStream in the Modbus4J library.
Please, could someone help me.