Custom Nodesets and DataType Handling #172
Replies: 3 comments 3 replies
-
Thank you for your message. (I am converting this issue into a discussion because it seems more appropriate for this kind of potentially open-ended exchange format.) Regarding encryption, we have now been able to incorporate Mbed TLS: easier than dynamically linking with OpenSSL. Take a look at #170 for more details. Regarding node sets, I think that this might best be approached in the form of Rust procedural macros. I find it quite hard to imagine how we would incorporate this into The procedural macro (possibly a derive macro) would also implement the Maybe we could look into what the Python nodeset builder does and can replicate this functionality in Rust? |
Beta Was this translation helpful? Give feedback.
-
I saw the Mbed TLS merge, looks good! A Rust macro would be the cleanest approach thats true. But we would need to generate the C-code at least once for the bindings to be generated. This can happen dynamically and that works fine with my approach. The Nodeset-Compiler will give a types header that includes all the infos we would need for a macro that generates a wrapper for each datatype. E.g:
I dont think we need to rebuild the nodeset generator. I did this in my master thesis with a recursive descent parser for XML files. Its not really straight forward because of all the references to other namespaces and nodesets. The information from the types header will be enough to create a datatype wrapper. I think a render/template engine like askama or mustache could do the trick. Im positive that including all this in the bindings generation process, would result in dynamic type generation for new datatypes. |
Beta Was this translation helpful? Give feedback.
-
I added my changes to forked repos: https://github.com/basyskom-dege/open62541_rust and here is a gist for using the rfid reader from the autoid: https://gist.github.com/basyskom-dege/676ce634fbe4d94261a6bb2c8899d311 It might not compile like this but i think you will get the idea. This is the instance of the rfid reader: |
Beta Was this translation helpful? Give feedback.
-
Hello!
Over the last week, I took a deeper dive into this project and the open62541-sys project. I explored some areas that are essential for real-world applications, specifically custom nodesets and encryption.
I managed to get encrypted endpoints running with my own certificate by modifying parts of the server API to access the config and then utilizing the generated bindings for the security functions.
As mentioned in #101, custom nodesets arent currently supported. I looked the issue and was able to use a custom nodeset with the open62541 nodeset compiler. I created a small CMake script that utilizes the CMake integration of the nodeset compiler. This includes a config file where you can specify the nodesets to generate, along with their paths, names, and dependencies.
I also modified the build.rs file in Open62541-sys to integrate the generated nodesets into the bindings generation process. This worked surprisingly well, and I was able to instantiate object nodes and use them.
The main challenge I encountered is with custom datatype handling. I managed to use the data_type! macro to generate the DataType trait and i only need to implement the actual setter and getter functions of the fields.
My question is: would you be interested in a pull request with these changes? I have an idea to use a template engine to dynamically generate custom datatypes via the modified data_type! macro and generation of getter and setter functions for each field, which would simplify the use of custom nodesets.
Let me know if you're interested, and Id be happy to clean up my code and open pull requests.
Beta Was this translation helpful? Give feedback.
All reactions