This topic is 5 years old, but there is still a lack of documentation.
I want to receive UDP packets by TINA and read the
profi driver manual and the example
AVR TINA_ENC_UDP. More specific information (about my task) I couldn't find in the forum and internet.
In general the AVR example is nice. Unfortunately it doesn't tell how to read out the received data in detail.
Configuration of example:
Code
//Construct the first Socket (xUDP)
UDP := TinaCreateSocket;
With UDP^ do
Protocol:= pxUDP;
LocalPort:= 8000;
RemotePort:= 1000;
RemoteHost:= IP;
PacketRecInfo.BufferPtr:= @MyBuf;
PacketRecInfo.BufferLen:= SizeOf(MyBuf);
endwith;
Receiving code of example:
Code
//Socket UDP
if TinaPacketReceived(UDP) then
//We receive a packet @Socket UDP
//We do nothing so dont block the Socket with trash! Lets resume !
TinaResumeReceive(UDP);
endif;
I suppose the received data is stored inside of
PacketRecInfo.BufferPtr.
Questions:
1.
How to read out the buffer?
I suppose the content is a Byte array with the length
BufferLen, which I have to convert to my wanted values.
Great would be an example how to read 4 bytes from the buffer (which I can convert to a Float type).
2.
What happens if the micro controller received 2 or more packets?
Is there only the next packet content in
BufferPtr or the content of all received packets?
What I want:
For my application I want to receive UPD packets with a byte list, which represents a "frame" of several values (Bytes, Floats and Integers). After reading the Byte array, I want to convert sub-arrays to the related types.