A protobuf compiler plugin for TwinCAT that generates POUs and DUTs from *.proto files.
- Download the latest version of the Protocol Buffers compiler (protoc) from the official release page.
- Extract the downloaded archive to a directory of your choice.
- Add the
bindirectory of the extracted archive to your system's PATH environment variable.
git clone https://github.com/TcHaxx/protoc-gen-twincat.git
cd protoc-gen-twincat- Ensure you have a
dotnetenvironment set up on your machine. - Run the following command to build the plugin:
dotnet build -c Release - Create or obtain your
.protofiles. CDintoproto/directory- Create the output directory, e.g.
.out/mkdir .out
- Run the following command to generate TwinCAT files:
protoc --plugin=protoc-gen-twincat=../src/protoc-gen-twincat/bin/Release/net9.0/protoc-gen-twincat.exe --twincat_out ../.out example.protoThis will generate the corresponding TcPOU and TcDUT files in the current directory.