kooroshtux
Good morning all !

I write this message in order to know if it is possible to recover or extract the code in C generated by openPLC?

I am worth doing this because I am programming in Python and QT an HMI interface and I would very much like to recover the program generated in C. Is it possible?

Best regards,
Quote 0 0
thiagoralves
I don't know why the C code would be valuable for your HMI application, but in any case, the C code for the running program is located in OpenPLC_v3/webserver/core/*.c and *.h (all the other .cpp files are internal to OpenPLC). You can also obtain the same *.c and *.h files running iec2c compiler (found in the utils folder) against your uploaded .st file like this
./iec2c my_st_file.st
Quote 0 0
kooroshtux
I just noticed that there is "wxglade hmi" for python in the Openplc directory, do you have any documentation or could you tell me how to develop my HMI interface directly on openPLC via wxglade?
Quote 0 0
thiagoralves
This is a feature from Beremiz that I disabled on OpenPLC exactly due to the lack of documentation on the functionality. The default route to build HMIs on OpenPLC is through ScadaBR
Quote 0 0
kooroshtux
Perfect, well I will deploy ScadaBR on my arduino in modbus serial communication and if I ever have a problem, I would return to this topic😉. Thank you
Quote 0 0
BenKissBox
kooroshtux wrote:
Good morning all !

I write this message in order to know if it is possible to recover or extract the code in C generated by openPLC?

I am worth doing this because I am programming in Python and QT an HMI interface and I would very much like to recover the program generated in C. Is it possible?

Best regards,


All the C source code generated from OpenPLC can be found in the /build folder of your project.
However, you have to take care of two things :
  • the files not only contain your IEC1131 code compiled into C, but they also contain many functions used for debugging
  • the C code is mainly based on macro definitions in the .c files. Don't expect to find C code as written by a human, the code structure is quite disturbing the first time you read it (but it does not matter for the gcc compiler)

This is just to warn you depending on what you intend to do with the code. Simply said, if you just intend to inject the code into a project being compiled with gcc, that will be very simple. If you want to extract the code to make a runtime on an embedded target like a microcontroller (which is perfectly possible), this is really more challenging (I had to write a code extractor to be able to compile the PLC code on XMOS microcontrollers)

Benoit
Quote 0 0
kooroshtux

Thank you very much for your very complete answer. the architecture will be that my two arduino are connected by ethernet via a shield. Then, the raspberry will be the brain which will contain openplc for programming but also a program in python which will collect the data of the two arduino to display them on my HMI. This GUI will not be able to control the physical equipment (for security) but just for monitoring and supervision.

It is the problem because if I had programmed my two arduino in arduino language it was good but I would like to carry out this idea with openPLC, except that I do not see how to do it. in the next few days I will deploy ScadaBR on mnon raspberry pi3 to control the arduino just to see the result but my goal is with python with my own HMI.
Quote 0 0
thiagoralves
Oh man! You don't have to do any of that! OpenPLC supports Arduino natively as slave devices. All you have to do is deploy OpenPLC firmware on your Arduinos, game over. Just read the Arduino section on the getting started guide for the runtime on the OpenPLCproject.com website. It will take you less than 10 minutes to setup your Arduinos with OpenPLC. No python middleware required! Then you can query all the data from the main OpenPLC host
Quote 0 0