Modbus Module Build

I am looking to modify the Modbus example module in order to communicate using a slightly different protocol. I downloaded the example from GitHub, and re-factored some of the classes to a new name for this new driver. Then I built it using mvn package, and installed it on my ignition gateway to see my progress. Later I tried using a test modbus server, which ignition would connect to, but not poll. I used ngrep to watch the communication from ignition to the modbus server, and ignition was connecting, but not sending anything out at all. Before I installed the driver that was built with Maven, the test modbus server worked well. I have ignition version 7.9.10.

Then I downloaded a fresh copy from GitHub, used mvn package to build it, and re-installed it. Then added a new device with this driver to connect to my test server, and had the same result. The tags in ignition go from Quality Disconnected, to Quality Unknown when the driver connects to my server, but it will not read the tags (have null values). Has anyone else been able to use the modbus driver from GitHub with version 7.9.10?

Another issue I have, is I am very new to Java, and I cannot find where the start/end delimeters are added to the modbus packet when it is sent out. I traced the packet generation as follows: AbstractModbusDriver defines ReadFactory/WriteFactory, which I’m guessing are used in the AbstractIODelegatingDriver. The factory will use different classes depending on the function code. Then it looks like AbstractModbusRequest will generate the packet using ModbusTCPTransport (if that’s what is selected). Then that will get the header from MBAPLayer, which get’s it from MBAPHeaderWriter in the structs package.

According to the modbus specficiation, the packet should start with a : (3A), and end with a \r\n (0D0A). It looks like when the driver receives a packet, the driver will look for these in the ModbusAddressLexer. Does anyone know where they are added to the outgoing packet? Is there any chance there will be more documentation for the functions that are extended from, such as the AbstractDriverModuleHook, or AbstractIODelegatingDriver? Thanks.

Okay… lots to unpack here.

I wouldn’t recommend doing this. The Modbus driver is now what I would consider a very poor example for building a driver. Mostly because the protocol implementation is convoluted and because there is no separation between protocol and driver. We’ve removed this example from the SDK in 8.0.

Maybe in the variant where frames are ASCII-encoded, but this driver does not implement that. ModbusAddressLexer is not what you’re looking for either.

The best recommendation I have is to get an implementation of your protocol working entirely separate from Ignition and then once you’ve got that done try to integrate it by implementing the Driver interface directly.

Is there a document that lists the methods the Driver needs? I read the old SDK document (http://files.inductiveautomation.com/sdk/ProgrammersGuide.pdf), that recommends extending from AbstractDriver, but I don’t know where to look to see what methods are in that class that I would be able to use. It’s not in the Modbus example that I can see.

Actually google figured it out http://files.inductiveautomation.com/sdk/javadoc/ignition784rc1/com/inductiveautomation/xopc/driver/api/AbstractDriver.html

There’s some 7.9 javadocs here

The Driver interface has some docs… but you’re not in well documented territory in general :slight_smile:

Hah! That smiley faces seems a bit out of place…