dellalba
Hello,

honestly, I don't know if it's a bug, it's expected, or a misconfiguration.
I connected OpenPLC to Factory I/O (scene 1), and everything is going fine, from the Flask Web interface I can see the variables monitored in almost real-time.

Now I need to connect HMI (ScadaBR) and other python scripts to OpenPLC Runtime using Modbus, and even if Factory I/O is updating registers (input/output) I cannot see those updates querying OpenPLC via Modbus.

OpenPLC is configured to read %IX100.0, and write %QX100.0.

With Python I'm simply looping and printing:

print("Coils: ", client.read_coils(0,8).bits)
print("Discrete: ", client.read_discrete_inputs(0,8,).bits)

But the loop is printing only the False value even if from the web interface they became True.

I'm using the last master version. I tried to debug what is going on, but I cannot understand how OpenPLC runtime is supposed to replicate registries from Factory I/O and back. I saw a post from 2018 declaring that this feature should be implemented.

Thank you very much

Andrea
Reply 0 0
thiagoralves

This line of code:

dellalba wrote:

print("Coils: ", client.read_coils(0,8).bits)

reads coils 0 through 7. Your slave device is located at QX100.0, which is Modbus coil 800. You’re simply reading from the wrong address, that’s why you’re not getting the data you want. Same goes for inputs

Reply 0 0
dellalba
Thank you @thiagoralves I came from the Cybersec world and I'm trying to understand the big picture. With your suggestion I make things work fine.

I have another strange behavior, but I guess it's by design: if I attack Factory I/O I can override the coil register and make the conveyor run despite of the PLC commands. The same attack tageting the OpenPLC is not working because, in my guess, the PLC program has a higher priority than the value I manually set.

Can you confirm that?

Thank you again for the great software you made.
Reply 0 0
thiagoralves
That’s correct. Ladder logic has priority over Modbus write requests. As for factory io, there is no intelligence in there, just like any other slave field device. They take whatever command they receive and execute.

Also, since OpenPLC is constantly writing back to Factory IO, your write request to Factory IO is quickly overwritten by OpenPLC. If you decrease the poll delay of slave devices on OpenPLC settings you will see that your Factory IO attack becomes less and less effective
Reply 0 0
dellalba
If I can see the default value to poll/update slave devices is 100ms. My script run faster (it's a sort of "while True: client.write_coil(address=800, value=True)"), but I cannot see any changes in factory I/O.
From a TCPdump I didn't see major differences between with and without the running script (even with a longer polling interval 500ms)

Compared to the PLC I see in plants, OpenPLC seems more robust 😉
Reply 0 0
Reply