Jiaoche
Raspberry PI:
# cat plugins.conf
modbus_slave,./core/src/drivers/plugins/python/modbus_slave/simple_modbus.py,0,0,./core/src/drivers/plugins/python/modbus_slave/modbus_slave_config.json,./venvs/modbus_slave
modbus_master,./core/src/drivers/plugins/python/modbus_master/modbus_master_plugin.py,0,0,./core/src/drivers/plugins/python/modbus_master/modbus_master.json,./venvs/modbus_master
s7comm,./build/plugins/libs7comm_plugin.so,0,1,./core/src/drivers/plugins/native/s7comm/s7comm_config.json
my_native_plugin,/home/tronlong/openplc-runtime-4.0.3/tests/mytest/my_native_plugin.so,1,1,/home/tronlong/openplc-runtime-4.0.3/tests/mytest/my_native_plugin.json
 
OpenPLC Editor:
[09:12:44]: [DEBUG] update_plugin_configurations called with generated_dir='core/generated'
[09:12:44]: [DEBUG] Looking for config files in: core/generated/conf
[09:12:44]: [DEBUG] Loaded 4 plugins from plugins.conf
[09:12:44]: [DEBUG] Initial state - modbus_slave: enabled=False, config_path='./core/src/drivers/plugins/python/modbus_slave/modbus_slave_config.json'
[09:12:44]: [DEBUG] Initial state - modbus_master: enabled=False, config_path='./core/src/drivers/plugins/python/modbus_master/modbus_master.json'
[09:12:44]: [DEBUG] Initial state - s7comm: enabled=False, config_path='./core/src/drivers/plugins/native/s7comm/s7comm_config.json'
[09:12:44]: [DEBUG] Initial state - my_native_plugin: enabled=True, config_path='/home/tronlong/openplc-runtime-4.0.3/tests/mytest/my_native_plugin.json'
[09:12:44]: No conf directory found in core/generated, disabling all plugins
[09:12:44]: Found 0 config files (no conf directory): []
[09:12:44]: Disabled plugin 'my_native_plugin' (no conf directory found)
[09:12:44]: Plugin configuration update complete. 1 plugins updated.
[09:12:44]: [DEBUG] Final state - modbus_slave: enabled=False, config_path='./core/src/drivers/plugins/python/modbus_slave/modbus_slave_config.json'
[09:12:44]: [DEBUG] Final state - modbus_master: enabled=False, config_path='./core/src/drivers/plugins/python/modbus_master/modbus_master.json'
[09:12:44]: [DEBUG] Final state - s7comm: enabled=False, config_path='./core/src/drivers/plugins/native/s7comm/s7comm_config.json'
[09:12:44]: [DEBUG] Final state - my_native_plugin: enabled=False, config_path='/home/tronlong/openplc-runtime-4.0.3/tests/mytest/my_native_plugin.json'
[09:12:44]: Plugin summary: 0/4 enabled (2 Python, 2 Native)
 
 
all plugin is not enabled,how to use plugins?
thiagoralves
As a user, you don’t have to do anything programmatically on the runtime to enable them. They are enabled according to the configuration in your PLC program. All plugins are loaded by default, but are only enabled if they are used. For example, if you want to enable Modbus slave plugin, on your PLC program click on the blue + button on the left panel, go to servers and pick Modbus to create a Modbus server (Modbus slave). Once you upload the program to the runtime you will see from the logs that the Modbus slave plugin was enabled.
Reply 0 0
Jiaoche
Thank you for your reply. I still have a question: my_native_plugin is a C/C++ plugin I wrote myself. Does this also follow the method described above? If it doesn't apply, how should I use this plugin?
Reply 0 0
Jiaoche
I followed the instructions at https://github.com/Autonomy-Logic/openplc-runtime/tree/development/core/src/drivers/README.md to compile the test_plugin and successfully ran ./build/plc_main on the board. As a student new to OpenPLC, I've struggled to find any tutorials online about using custom plugins in the OpenPLC Editor. Could you please teach me? Or give me a reference example?
 
Below is the information from running ./build/plc_main:
# ./build/plc_main
[PLUGIN_CONFIG]: Found config_path: './core/src/drivers/plugins/python/modbus_slave/modbus_slave_config.json'
[PLUGIN_CONFIG]: Found config_path: './core/src/drivers/plugins/python/modbus_master/modbus_master.json'
[PLUGIN_CONFIG]: Found config_path: './core/src/drivers/plugins/python/opcua/opcua.json'
[PLUGIN_CONFIG]: Found config_path: './core/src/drivers/plugins/native/s7comm/s7comm_config.json
'
[PLUGIN_CONFIG]: No config_path found, using empty string
[PLUGIN] Using venv for modbus_slave: ./venvs/modbus_slave/lib/python3.10/site-packages
Python plugin 'simple_modbus' symbols loaded successfully
- init: (PASS)
- start_loop: (PASS)
- stop_loop: (PASS)
- cleanup: (PASS)
[PLUGIN] Using venv for modbus_master: ./venvs/modbus_master/lib/python3.10/site-packages
Python plugin 'modbus_master_plugin' symbols loaded successfully
- init: (PASS)
- start_loop: (PASS)
- stop_loop: (PASS)
- cleanup: (PASS)
[PLUGIN] Using venv for opcua: ./venvs/opcua/lib/python3.10/site-packages
Python plugin 'plugin' symbols loaded successfully
- init: (PASS)
- start_loop: (PASS)
- stop_loop: (PASS)
- cleanup: (PASS)
Native plugin './build/plugins/libs7comm_plugin.so' symbols loaded successfully
- init: (PASS)
- start_loop: (PASS)
- stop_loop: (PASS)
- cycle_start: (PASS)
- cycle_end: (PASS)
- cleanup: (PASS)
Native plugin '/root/openplc-runtime/core/src/drivers/plugins/native/examples/test_plugin.so' symbols loaded successfully
- init: (PASS)
- start_loop: (PASS)
- stop_loop: (PASS)
- cycle_start: (PASS)
- cycle_end: (PASS)
- cleanup: (PASS)
[PLUGIN]: Skipping disabled plugin: modbus_slave
[PLUGIN]: Skipping disabled plugin: modbus_master
[PLUGIN]: Skipping disabled plugin: opcua
[PLUGIN]: Skipping disabled plugin: s7comm
[PLUGIN]: Generating structured args for plugin type 1
[PLUGIN]: Allocated runtime args structure (size: 496 bytes)
[PLUGIN]: Returning native plugin args
[TEST_PLUGIN] Warning: runtime_args is NULL, logging will fall back to printf
[TEST_PLUGIN] [INFO] Initializing test plugin...
[PLUGIN]: Skipping disabled plugin during start: modbus_slave
[PLUGIN]: Skipping disabled plugin during start: modbus_master
[PLUGIN]: Skipping disabled plugin during start: opcua
[PLUGIN]: Skipping disabled plugin during start: s7comm
[PLUGIN]: Native plugin test_plugin started successfully.
Reply 0 0
thiagoralves
Plugins are managed through the plugins.conf file in the project root. After compiling your plugin (as you did with test_plugin), you need to:
1. Add an entry to plugins.conf with enabled=1
2. Run ./build/plc_main and your plugin will load
 
However, there's an important caveat: plugins.conf is dynamically managed by the OpenPLC Editor. When you upload a new program from the Editor, the runtime scans the uploaded project for a conf/ folder containing JSON config files. Plugins with matching config files (e.g., conf/modbus_slave.json) are automatically enabled on plugins.conf, and plugins without matching config files are automatically disabled on plugins.conf. This means any manual changes you make to plugins.conf will be overwritten on the next upload from the Editor.
 
There is no mechanism yet for "persistent" or "manual" plugins that stay enabled independently of what the Editor uploads. This is a gap we're aware of. If you want to use a custom plugin without modifying the Editor, the workaround for now is to manually edit plugins.conf and run the runtime directly (./start_openplc.sh), but avoid uploading new programs from the Editor, or be prepared to re-enable your plugin after each upload. We're considering adding support for persistent plugins in a future update.
Reply 1 0
Jiaoche
Plugins are managed through the plugins.conf file in the project root. After compiling your plugin (as you did with test_plugin), you need to:
1. Add an entry to plugins.conf with enabled=1
2. Run ./build/plc_main and your plugin will load
 
However, there's an important caveat: plugins.conf is dynamically managed by the OpenPLC Editor. When you upload a new program from the Editor, the runtime scans the uploaded project for a conf/ folder containing JSON config files. Plugins with matching config files (e.g., conf/modbus_slave.json) are automatically enabled on plugins.conf, and plugins without matching config files are automatically disabled on plugins.conf. This means any manual changes you make to plugins.conf will be overwritten on the next upload from the Editor.
 
There is no mechanism yet for "persistent" or "manual" plugins that stay enabled independently of what the Editor uploads. This is a gap we're aware of. If you want to use a custom plugin without modifying the Editor, the workaround for now is to manually edit plugins.conf and run the runtime directly (./start_openplc.sh), but avoid uploading new programs from the Editor, or be prepared to re-enable your plugin after each upload. We're considering adding support for persistent plugins in a future update.
Got it. Thanks for the clear explanation. Much appreciated!
Reply 1 0
Jiaoche
I want to ask, when will this problem be resolved?
Reply 0 0
thiagoralves
We don't have a change planned for this on our roadmap. So far the architecture of plugins are tied to the editor, and we don't think it would be interesting to change that as the editor is ultimately what drives the plugin configuration. So essentially, any new plugin on the runtime requires changes on the editor as well
Reply 1 0
Jiaoche
If the plugin is custom, how should we add a new plugin in the editor?
Reply 0 0
thiagoralves
What does your plugin do? In general plugins will require some configuration, for example, the Modbus slave plugin needs to know how many addresses will be available, which types of data, etc. Therefore, there is a screen on the editor to configure this and also a .json plugin file that contains this configuration. The presence of this json file is what makes the runtime activate the plugin on the plugins.conf
Reply 0 0
Jiaoche
What does your plugin do? In general plugins will require some configuration, for example, the Modbus slave plugin needs to know how many addresses will be available, which types of data, etc. Therefore, there is a screen on the editor to configure this and also a .json plugin file that contains this configuration. The presence of this json file is what makes the runtime activate the plugin on the plugins.conf
I defined the input and output pins of my own board using the plugin. Can I define something like this in the editor, similar to a Raspberry Pi?
[203128%2F9790607%2Fmceclip0]
Reply 0 0
Reply