This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMDS64EVM: PROFINET device demo data endianess

Part Number: TMDS64EVM
Other Parts Discussed in Thread: PROFIBUS

Hello.

I'm using the PROFINET device demo from Industrial communication SDK 11.00.00.13, and I'm wondering, that the process output data in the demo application callback function

PN_APP_IOD_cbDataRead(PN_API_IOD_Handle_t *const pnHandle, PN_API_IOD_DevAddr_t *const addr, const uint32_t bufLen, uint8_t *const buffer, const PN_API_IOD_IOXS remoteIops)

after the buffer pointer are provided in big endian format. I expected littel endian format.

With the process input data copied to the buffer pointer within function PN_APP_IOD_cbDataWrite(PN_API_IOD_Handle_t *const pnHandle, PN_API_IOD_DevAddr_t *const addr, const uint32_t bufLen, uint8_t *const buffer, const PN_API_IOD_IOXS remoteIocs)

it is the same. I have to copy the process input data also in big endian format.

I didn't read something about big/little endian format, thus I expected little endian format. This is also the configuration within the project properties for the ARM compiler ("-mlittle-endian").

Do you have an explanation?

  • Hello,

    I'm not sure I understand your question. Would you please clarify more? is your problem about the way we store data? or the data format on the network?

    You give the data in big-endian format and it is stored in little-endian format as per compiler configuration.

    Kind regards,
    Kamil

  • Hello.

    I'm just wondering, that the data stored behind the buffer pointer of functions PN_APP_IOD_cbDataRead() is big endian format respectively of function PN_APP_IOD_cbDataWrite() must be provided after the buffer pointer in big endian format.

    Thus, the way the process data is stored by the PROFINET device stack.

    My expectation was, that the PROFINET device stack will provide the process data in little endian format, so that I can use memcpy() to handle the process data in my application also in little endian format.

    Regards,

    Sebastian

  • Hello Sebastian,

    I just checked on my side and it seems that the data provided to the buffer inside PN_APP_IOD_cbDataWrite() is stored in Little-Endian format.



    isn't this what you actually want?

    Thanks.
    Kind regards,
    Kamil

  • Hello again.

    Thank you for your support until now.

    Excuse me, I've narrowed the focus a little.
    We need to consider the entire data transfer from the PROFINET I/O controller to the TMDS64EVM development board.
    When I use the GSDML file, I have a 2 byte and a 4 byte standard data point in the PROFINET I/O Controller (Siemens S7-1500). Look at the picture.

    If I now send a constant value (0x12345678) from the PROFINET I/O controller to the 4-byte data point via slot 1, subslot 2, it arrives in big endian format in the PROFINET device stack.

    Constant data within PROFINET I/O controller:

    Big endian format of constant data "0x12345678" after the buffer pointer to be copied to the demoOutData[] array within function PN_APP_IOD_cbDataRead().

    Content of demoOutData[] array after the memcpy() of the constant data after the buffer pointer.

    Of course, this is just the way of the output process data. But things are going in a similar way in the opposite direction.

    I simply do not understand where the byte order is rotated.

    Thank you for your continued support,

    Sebastian

  • Hello Sebastian,

    thanks for the clarification. I will check your concern and get back to you ASAP.

    Kind regards,
    Kamil

  • Hi Sebastian,

    I tried this one my side and observed the following (which corresponds to what you described before):
    - Output data: the data is handed to the end user via PN_APP_IOD_cbDataRead() exactly in the same byte-order sent by the PLC.
    - Input data: the data is sent to the PLC exactly in the same byte-order provided by the end user via PN_APP_IOD_cbDataWrite().

    According to the standard, PROFINET by default uses Big-Endian format to handle data, so the stack's behavior makes sense so far for me.
    However, if you would like to switch the data representation to another format, you can add the following functions to pn_app_iod_data.c and use them when required:

    extern uint16_t OsHtons(uint16_t);
    extern uint16_t OsNtohs(uint16_t);
    extern uint32_t OsHtonl(uint32_t);
    extern uint32_t OsNtohl(uint32_t);

    If you have further concerns, please feel free to discuss them here.

    Kind regards,
    Kamil

  • Hello, Kamil.

    I hope you have come to the new year 2026 well.

    First of all, thank you for your support.

    The PROFIBUS/PROFINET data is handled in Big Endian format, which is true.
    It would be desirable if the format of the data, as it arrives at the corresponding functions in the PROFINET example application, were also documented.

    Kind regards,
    Sebastian