kortenbach
How can I build (binary) function-blocks that contain (hidden) c-code?
If this would be possible then people could write blocks that perform complex functions like:
- http server
- serial communication
- bluetooth
- Watchdog triggering
- etc.
Maybe this is possible by using structured text?
Quote 0 0
thiagoralves
Yes, this is possible with the use of pragmas on structured text blocks. Check:  https://openplc.discussion.community/post/command-exec-in-openplc-rpi-9707083?pid=1303821827&highlight=shutdown
Quote 0 0
kortenbach
Wow! That looks promising... Thanks for the reply!
Quote 0 0
kortenbach
My next question would be (ESP8266/ESP32):
- Do function blocks for http server etc already exist?
I did some research but couldn't find any...
Quote 0 0
thiagoralves
No, there aren’t any web server blocks, especially given the fact that the runtime does not actually run on the esp, but it is used as a slave device only. You can write C code to create a simple web server on the host running the OpenPLC runtime though. I just don’t know how useful that would be for a PLC...
Quote 0 0
kortenbach
Modifying the host probably means modifying the openplc firmware, right?
I think an HTTP server is the best way to get an HMI going. I'm working on a library of SVG symbols to build a web page. Would be nice to have an HMI without any client-side software. What do you think?
Quote 0 0
thiagoralves
kortenbach wrote:
Modifying the host probably means modifying the openplc firmware, right?

No, the host is where the OpenPLC runtime runs (raspberry pi, windows PC or Linux). If you insert C code to create a webserver embedded on a block, it will run on the host, not on the ESP which is just a slave device. Slave devices only run modbus slave code to communicate with the host, nothing else.


If you want a web based HMI you should try ScadaBR (check openplcproject.com website). It is the easiest way to go, and given that it is web based, there is no software needed (besides a browser) on the client side
Quote 0 0
kortenbach
Ok, I completely misunderstood the concept of esp 8266 in combination with open PLC. I thought that the esp was actually running the PLC code... Bummer...
Quote 0 0
kortenbach
With Arduino it's the same story I guess?
Quote 0 0
thiagoralves

Yup. All slave devices run as.. well.. slave devices.

There is a guy here in the forum that actually started working on porting the runtime code to run on a esp32. He has some beta version on his GitHub repository that is actually capable of running full blown OpenPLC code on it. So far it seems that the only limitation is that it does not have modbus or dnp3

Quote 0 0
thiagoralves
Here is the link if you want to check it out:  https://openplc.discussion.community/post/proof-of-concept-port-of-openplc-core-to-mcu-platformioarduinoesp32-10245850?pid=1309519850
Quote 0 0
kortenbach
 I'll check it out!, This could be nice after all ;-)
Quote 0 0