Network Byte Orders

Inna
2021-01-11
2021-01-12
  • Inna - 2021-01-11

    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

     
  • MadsKaizer

    MadsKaizer - 2021-01-12

    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

Log in to post a comment.