This is pretty much the format that most, if not all, industrial control protocols (e.g. EtherNet/IP, S7, SLMP) follow. Some header that specifies command type and length of the message and is followed by the message data itself. The best way to handle this would be to create a byte array, then use sysmem.cpy and copy the bytes into such array to be sent other some medium (e.g. Ethernet).
Anyway, then have TCP write client send this out. As the receive part, just do the same thing. Create a struct and copy from the receive buffer back into a STRUCT for "easy" parsing.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Someone have a library to encode TLV data to Codesys?
Last edit: damian177 2021-12-23
Hi,
Personally I never came across such a library. But that said, reading https://en.m.wikipedia.org/wiki/Type%E2%80%93length%E2%80%93value at first glance it seems not too difficult to implement an encoder/decoder.
good luck and merry Christmas 🎄⛄
@damian177,
This is pretty much the format that most, if not all, industrial control protocols (e.g. EtherNet/IP, S7, SLMP) follow. Some header that specifies command type and length of the message and is followed by the message data itself. The best way to handle this would be to create a byte array, then use sysmem.cpy and copy the bytes into such array to be sent other some medium (e.g. Ethernet).
Anyway, then have TCP write client send this out. As the receive part, just do the same thing. Create a struct and copy from the receive buffer back into a STRUCT for "easy" parsing.