OSCAT Forum

network.lib => BECKHOFF => Thema gestartet von: bartmarchand am 21. April 2019, 15:47:29

Titel: Send/receive string with UDP
Beitrag von: bartmarchand am 21. April 2019, 15:47:29
Hi there,

I'm trying to send this string: '20 00 00 00 16 02 62 3A D5 ED A3 01 AE 08 2D 46 61 41 A7 F6 DC AF D3 E6 00 00 1E' of hexadecimal values over UDP to an IP address.
I should receive this answer: '28 00 00 00 11 00 02 98 D8 63 35 D2 EA F6 C3 DC 00 01 7B 02 00' for further analysis.

I think I could use the http demo example for this, however, I do not understand the url_text syntax for this.
Can you point me in the right direction?
Titel: Re: Send/receive string with UDP
Beitrag von: peewit am 22. April 2019, 16:40:07
This has nothing to do with http.

http uses tcp connections

you simply have to parameterize a udp connection with ip_control and then write the byte data into the send buffer and enter the data length and send it
Titel: Re: Send/receive string with UDP
Beitrag von: bartmarchand am 23. April 2019, 20:47:53
Hi peewit,
thank you for the quick response, as usual.

It's too hard for me to understand this udp transfer, it's too long ago that I was in this kind of programming, my fault...
Is it possible to give me an example on how it's done?
Titel: Re: Send/receive string with UDP
Beitrag von: bartmarchand am 24. April 2019, 15:08:36
OK, a small succes for now.

With the fb IP_Control, it is possible for me to sent a string to a predefined IP address.
I'm starting the transfert by setting IP_C.C_ENABLE to TRUE.

For testing, I sent an UDP string to my pc, where an app "UDP Client Server" is running.

However, as long as C_ENABLE is TRUE the same string is transfered again and again.
How can it be adapted so that the transfer stops after 1 transfer?
Titel: Re: Send/receive string with UDP
Beitrag von: peewit am 26. April 2019, 15:40:33
as soon as a data length is entered in S_BUF.SIZE, the data is sent and then automatically set to 0 by the IP_Control module.

you probably write every cycle the data length in S_BUF.SIZE

therefore the data is sent again and again