Modbus/TCP write issues

I have done a bunch of searching on this topic but haven't really found any answers that seem to fit so I apologize if its a redundant topic.
I have a modbus/TCP connection to a Pacmac bagger.
I am getting the read side no problem but when I got to write to a coil to reset some counters I am getting bad data
Here is the error from the log


Ive made most of the changes I saw in the previous posts around the device connection. Here is where I am at now



Once I click the button I set up to write to the Boolean bit all my tags go bad and when it comes back it was reset.

Can you get a Wireshark capture?

I will work on that angle but it may take several months to get IT and corp security to install it

Well, that's not strictly necessary I guess.

The problem here is your device has a broken Modbus implementation. The response it's returning is 1 byte short.

3e 25   tx id
00 00   protocol version
00 05   frame length
00      unit id
05      function code
01 f8   output address
ff      output value (should be 2 bytes)

This isn't a configuration issue. Any time you do this write and get this broken response the driver is going to throw an error and reconnect, and you'll get bad tag quality and a failed write response to go with that event.

Any way to work around it?

If you initiated the write from a script, and used system.opc.writeValue instead of system.tag.writeBlocking, you could just ignore the bad quality that gets reported. I may be wrong about this causing the driver to reconnect.

But you should also report this to the vendor of that device. The reason I wanted a Wireshark capture is it presents a more objective view of what's going on, rather than trusting the logs from one of the software involved.

Yeah typing the email to the vendor as we speak....

So the writeValue will automatically ignore the bad quality? Or is there more script I need to ignore it...
I am using a one shot button so will try and script with a momentary button

writeValue returns a quality and it's up to you as the script author to do something with it (or not).

Used momentary button and scripted as discussed above...


Same error code and same results??

The error in the logs is never going to go away.

The best you can hope for is that you are just able to make the write happen and ignore the bad quality result and log message.

So its the error in the logs that causes all the data go to bad quality and unless I can get the OEM to fix what they send im sunk?

It's not totally clear to me why the rest of your data goes bad quality. Maybe if you provided full logs and a Wireshark capture I could tell you more.

It's possible that missing byte is showing up at the front of the next response, in which case yes, everything is properly f8cked and you need the OEM to fix their broken Modbus implementation.

1 Like

You could work around it with my Advanced Modbus Driver's scripted system.opc.rawModbus() utility function. You'd generate your own "Write Single Coil" payload, and lie about the expected response length to match what this dumb device is doing.

Ewww. Can't handle that case, though.

1 Like

Ah ha
So they are wrong as suspected. They are saying to work around I can write to multiple registers.
Not seeing in my head how to make that happen. I am assuming I can send some sort of Binary value like'010' or '100' to trigger the correct register but how do I set that up as a tag?

You don't set that up as a tag. Just provide a list of consecutive tags and corresponding list of booleans to system.tag.writeBlocking() and the driver will combine into a single function code.