Skip to content

What is the definition of the array after the structure variable is converted into a byte array by the pack function block?

Hello Sir,

I need to use the pack function block, the test can be normal, but how to define the converted byte array?

Comments

  • Hello,

    The DST output from the PACK function block is a byte array in proprietary format. There is no other information provided about this proprietary format in the documentation, so this will make it difficult to understand the individual values in your MB1 array.

    The only thing you can do with your MB1 array is pass it as the SRC parameter to an UNPACK function block, where the data will be unpacked into your com2_db2 structure. It is not necessary to understand the proprietary format of the byte array to use the PACK and UNPACK functions.

    I hope this helps.

    ~ Martin.

     

  • Hello Sir,

    Unpacking is normal, but I need to put the byte array into the Modbus array, some bytes of which are unnecessary.

    But I don't know what needs to be eliminated

  • Hello,

    Please check if the MEMORY_COPY function will do what you want.

    An example is shown below.

    Note that variables in a Struct are aligned on Word (16 bit) boundaries, so there may be padding bytes included in the resulting byte array.

    C4BC0129 9289 42A1 AD32 5031E3E2FFEB

    Hope this helps.

    ~ Martin.

Sign In or Register to comment.