PLCNext and Rust
Hi, what will be the story with using Rust on the PLCnext controllers?
What will be the Rust interface to the PLC program?
Will it also be possible to interface with Rust against the Codesys runtime?
Thanks!
Hi, what will be the story with using Rust on the PLCnext controllers?
What will be the Rust interface to the PLC program?
Will it also be possible to interface with Rust against the Codesys runtime?
Thanks!
Comments
Hello,
There is currently no direct support for rust, and nothing planned in the near future, as far as I am aware.
Out of interest - what application do you have in mind?
The following have been tried and confirmed to work OK:
The above can be built for the AXC F 2152 using the
--target=armv7-unknown-linux-gnueabihf
build option but, without the ability to interact more tightly with the PLCnext runtime platform, the range of useful rust applications for PLCnext is fairly limited.However ... I am currently working on a side project in my spare time. I have created rust wrappers for the PLCnext ANSI-C libraries used in this sample project, and this gives a native rust exe the ability to directly* control Axioline I/O, among a few other things. I am hoping to have a beta version of these wrappers available in the next few weeks, but I can't promise anything.
To give you a teaser (and to give you an idea of what the interface might look like), here is some code I got working this morning on my AXC F 2152. It just cycles a bit through the 8 channels of an Axioline digital output module:
Is this something that might be useful for your application? If so, it might give me some motivation to keep working on it. :)
As for codesys - I don't know. You would need to check this with the people at 3S.
( * as directly as we're allowed by the PLCnext platform. )
If you just want to exchange data between your rust program and the PLC program (written in an IEC-61131 language, for example), then you could use the industry-standard OPC UA server that is built in to the PLC. You should be able to find an OPC UA Client for rust, something like this one.
- Martin.
Hi, thanks for a great answer. I have no specific application in mind, just investigating the possibilities in the Plcnext platform. As you are aware of, Rust has some advantages compared to C++, but this is a bigger discussion.
I can for sure see the usefulness in your Rust wrapper, even though I dont have a specific usecase right now.
OPC UA was a good suggestion.
It seems from the ANSI C example project that I can also transfer data via GDS?
Thanks
Hello,
I agree that rust has advantages over C++, and unlike other popular new languages, it is perfectly suited for super-fast, deterministic, real-time applications ... like industrial controllers. Combined with the PLCnext Control hardware, there are some very interesting applications to be explored.
The Sample Runtime example mixes calls to the ANSI-C libraries with calls to the "standard" PLCnext C++ libraries, so it can be a little unclear where the separation is.
The ANSI-C libraries exchange data with Axioline I/O via GDS ports, but my understanding is that the ANSI-C library currently limits access to the "fieldbus" part of the GDS. This means that other parts of the GDS - e.g. ports on programs and components - cannot be accessed through the ANSI-C interface. I will need to confirm this, but it's a safe assumption at this stage.
Of course it would be very useful to be able to access the entire GDS (and all RSC services) through ANSI-C interfaces. I guess this will depend on the demand for this feature, and the relative priority it has among all the other features currently being worked on.
Well, I will continue working on the plcnext rust crate ... I will post something in the Makers Blog if/when there is something useable available on crates.io.
- Martin.
Great! I will for sure keep myself updated on the developments. Exciting times! ?