Up to now I’ve been controlling my Ifos slaves with a simple Modbus master I wrote in Ruby. In preparation for the move to TINI, though, I thought I’d better investigate Modbus master code actually capable of running there.
jamod is the logical first choice, since it’s Java-based and fairly mature. TINI runs Java, and if jamod complies with the Modbus application protocol specification, everything should just work.
Before jumping straight to the TINI, though, I thought it best to get things working from the Mac—it’s just so much easier to develop there. Here’s my basic jamod-based test program:
Modbus in ASCII mode uses an LRC to verify packets, and using the program above I immediately discovered a problem in how I handled this checksum. The algorithm is dead simple, however, and I quickly verified my PIC assembler implementation produced the correct results; it turns out my interpretation of the spec was just wrong. I still think my interpretation is the correct one—someday I’ll list all the things Modbus does wrong.
After a quick-and-dirty (and temporary) update to ignore checksum errors, Ifos started responding to jamod! Checksums on return messages are still generated incorrectly, so jamod complains about them, but at least Ifos is processing the incoming messages. jamod actually behaves as though no response is received at all, which is a little worrisome (I would expect something like, “Bad Checksum,” or similar), but I’m keeping my fingers crossed that fixing the LRC will make everything rainbows and unicorns.