Hello,
We have a system with PLCs with different byte order conventions - little endian/big endian.
I'm looking for Codesys routines for converting data between a host's internal representation and Network Byte Order(like htons() and ntohs()).
Thanks in advance
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You could use a struct "Union", in this example I always read out the real value in the code where I use the value, but I can switch around on the word0 and word1 when writing into the union from the MODBUS register.
Last edit: MadsKaizer 2021-01-12
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
We have a system with PLCs with different byte order conventions - little endian/big endian.
I'm looking for Codesys routines for converting data between a host's internal representation and Network Byte Order(like htons() and ntohs()).
Thanks in advance
Scroll down to programming: https://disorder.dk/wonderware/2020/10/07/modbus-tcp-between-codesys-controllers/
You could use a struct "Union", in this example I always read out the real value in the code where I use the value, but I can switch around on the word0 and word1 when writing into the union from the MODBUS register.
Last edit: MadsKaizer 2021-01-12