OPC UA is a platform independent standard for data modeling and communication that plays a major role in the horizontal and vertical integration of industrial automation systems. It is also a popular choice for connecting industrial controllers (PLCs) and entire machines with HMIs. Having an OPC UA client available is an important building block for popularizing Flutter for machine control applications.
Two years have passed since we at basysKom first attempted to use the open62541 OPC UA implementation in Flutter which resulted in a blog post describing our experience and the difficulties we encountered (for context have a quick look at the old post). Now it was time to have a fresh look into the matter to see if any of the blockers have been resolved.
Using open62541 directly via ffigen
The original blog post focused on the implementation of a C++ class providing a small, application specific subset of open62541's functionality to Flutter because it became clear quickly that using the library directly via ffigen wouldn't work.
The main blocker was that the open62541 code base makes heavy use of static inline functions in headers which was not supported by ffigen.
The Inline Problem
Static inline functions are still not supported by ffigen but starting with the upcoming 1.4 release of open62541, there will be a new CMake parameter named UA_ENABLE_INLINABLE_EXPORT which causes all static inline functions to be included into the the library. This solves the problem and ffigen is able to generate bindings for all functions in the open62541 library.
Threads and Callbacks
The next issue is not a blocker per se, but something to keep in mind. Due to the threading model of Dart, there can only be one thread per isolate. This demands that callbacks in the Dart code that are invoked from the native C side must not come from a different thread (e. g. worker thread) or the Dart VM will be terminated with an error
John Morgan
Dec 1, 2023, 5:27 PM
I am so confident that flutter will become one of the key technologies for the future industries
Mykola Pryhodskyi
Mar 30, 2024, 7:45 PM
Me also
Leave a Comment
Your Email address will not be published
KDAB is committed to ensuring that your privacy is protected.
For more information about our Privacy Policy, please read our privacy policy