davenardella
I am working on the integration of the S7 protocol in OpenPLC using my Snap7 libraries.
S7Protocol is a structurally complex protocol but it is very performant and secure (from the point of view of data integrity).
The Server part completely emulates a Siemens communication processor, once activated, OpenPLC is seen from the outside (including Step7) as a Siemens S7-315 PN/DP CPU.
All scadas that implement this protocol can read and write internal resources.
 
Current status

I have grafted the library into OpenPLC maintaining the existing conventions: there is an option file (s7protocol) in /script that if it contains the string s7ptrotocol, at the first compilation of a new PLC program, the wrapper files are automatically included in the compilation; otherwise they are deleted and no reference to them remains.

In Linux/Raspberry the library is compiled during the OpenPLC installation, so they will always be aligned with the libcc and the architecture (32/64).
In Windows I use the compiled (VisualStudio) dll wich are smaller and more performant.(However, if you want you can recompile them with mingw32/64, there is a makefile into the official Snap7 distribution).
 
Ultimately the changes are very non-intrusive, I added the snap7_src folder to /utils and modified 3 files ( background_installer.sh , compile_program.sh and main.cpp).
 
Install (Raspberry)
install.png
 
Compile user program
compile.png
 
Run program (Raspberry)
start.png
 
Client connected to Windows OpenPLC
snap7client.png
 
 
I currently have it implemented on
  • Windows (msys2)
  • Linux
  • Raspberry
Now all the work will be done only in the oplc_snap7.cpp file that in addition to containing the wrapper of the communication functions, manages the interface with OpenPLC.
 
and here we come to the second part...
Reply 1 0
davenardella
This is great! Thanks for finding the bug Dave! Indeed this bug has been reported a couple times, but I never had a chance to stop and look at it throughly. I'm glad you were able to find it and fix it. So how is the Snap7 implementation on OpenPLC? Does it depend on Modbus to work? Are you planing to push a PR with the changes soon?
 
By the way, I see you are using the new editor on your tests. How has been your experience with it so far? Have you tried the new 4.0.1-beta released this week?
This is the beauty of open source 😉
I'm afraid of glitches because very often they hide something more important.
 
No, snap7 is independent of modbus and its buffers and all other drivers, it works only on OpenPLC internal buffers (*int_memory[], *int_input[] and so on...).
I got to modbus.cpp because %MW0 was working fine with Snap7 (since I use internal buffers) but it was not being monitored. So I looked at monitoring.py and saw that it was using modbus internally...
 
Yes, I will do a PR as soon as I finish testing on all platforms, I just finished Linux and I'm about to switch to Raspberry (but I don't expect any surprises).
If I have time I try to use valgrind with openplc launched as a standalone executable (I saw that the communication works well) and I leave it under bombardment during the night to understand if there are some memory leaks...
 
Yes, I'm using OpenPLC Editor 4.0.1, it's very very nice and clean.
It's not fully "synced" with iec2c yet, sometimes it allows to do some things that are blocked by iec2c... like using % variables directly or initializing externals...
But I haven't looked into it yet, I'll take a closer look at it later.😉
Reply 0 0
thiagoralves
This is the beauty of open source 😉
 
I love it! Thanks for the great contributions you give
Reply 1 0
davenardella
valgrind.png
 
sounds good
Reply 0 0
Reply