eclipse
Hello,
I'm implementing OpenPLC on a high assurance security kernel.  To do so, and in anticipation of using Mandatory Access Controls to protect code and data buffers from unauthorized alteration, I'm working through the various data buffers, who writes and reads from which, and what locks are used for which.  If you have a detailed description that would be very helpful.

I have a question about the relationship between  the code in core (modbus.cpp) and the libmodbus_src library (e.g., modbus.c).  It appears that the libmodbus_src is NOT thread-safe (no mutexes), but the core code is.  Do I have that right?

Also, I'm not seeing a server-RTU sort of thing in core - is that basically just a modified libmodbus_src/tests/bandwidth-server-one.c program?

Thanks,
Ed
Ed Reed, Aesec
Quote 0 0
eclipse

So, actually paying attention to what the comments say, modbus.cpp functions have leading comments saying each is an "Implementation of Modbus/TCP <whatever function>".  And, indeed, these are the ones that include the mutex calls.

So - is it fair for me to conclude that 1) the libmodbus_src/src/modbus.c routine is expected to provide appropriate functionalities for a Modbus-RTU (as opposed to Modbus-TCP) implementation, where one Modbus interface (the RTU) and one hardware_layer backend are all that is involved, or 2) that no one is really doing that much with Modbus-RTU and all the attention is on Modbus-TCP and the new dnp3 protocol?

Inquiring minds and all that.

Ed Reed, Aesec
Quote 0 0
thiagoralves
I’m just throwing a quick answer in a hurry. If you need more details I can give a better explanation. But basically, modbus.cpp is responsible for handling all Modbus requests. It is OpenPLC’s Modbus server that you can enable/disable on settings. The libmodbus is a Modbus library that gets compiled when OpenPLC is installed. It is used only for the modbus slave devices that can be added to OpenPLC (modbus client). The implementation is done on modus_master.cpp. The mutexes are implemented in that file.
Quote 0 0
eclipse
Yes, that helps. I’ll share more about my project in the coming days. Anyone else working with RTU?
Ed Reed, Aesec
Quote 0 0
thiagoralves
As far as I know there is no code for Modbus RTU server, just TCP. However, as I said before, there is support for Modbus RTU client to connect to other Modbus RTU servers as slave devices
Quote 0 0
eclipse
Okay - that tracks with what I see.  I plan to cobble together a Server-RTU that will serve an RTU-based client and will try to provide that to you along the way.  Basically, it will be the libmodbus_src/tests/bandwidth-server-one.c code to start with.  It will morph by paralleling the server.cpp code, but setting up modbus-rtu context in place of "waitForClient" and using that in place of "read" in "listenToClient".  "processMessage" will then use the context, as well, to send the reply in lieu of "write".

It may also be of interest that I'm using external, indirect (e.g., addressed via pointers) segments as shared memory for shared databases and buffers, and full processes in lieu of POSIX threads (we don't have an MLS threads implementation to work with).

At present, we envision using 3 or perhaps 4 separate Mandatory integrity domains (ala Biba) to protect higher integrity processes and their data from corruption by lower-integrity-level processes.

Regards,
Ed
Ed Reed, Aesec
Quote 0 0