Avisaro Online Documentation - Wiki
Impressum Kontakt Sitemap

UDPOPEN

Description

The UDPOPEN command can be used to open an UDP communication channel. UDPOPEN requires six arguments:

1. A handle number in the range from 201 to 300. This handle will be used for subsequent communication.

2. An IP address of the receiving UDP. Use RESOLV to convert a dotted IP address into a properly integer number.

3. The TX port number. This is the port number for outgoing packets. Port numbers are in the range 0...65535

4. The RX port number. This is the port number for incoming packets.

5. A TX delay value in milliseconds. This value is only used when doing UDP streaming.

6. A checksum flag, either 1 or 0. If 0 is given, outgoing UDP packets have no checksum.

Example

This little application opens an UDP broadcast channel (IP address with all 255's) for reception and transmission, both on port 25. When it receives a packet, its length will be printed. Furthermore, the string "hello word" is sent out in 100 ms intervals.

outmode -2
let a = resolv ("255.255.255.255")
udpopen 201, a, 25, 25, 5, 0
let a$ = "hello world"
dim in1(1500)
do
   sleep 100
   put 201,a$
   get 201, in1
   if bytesread <> 0 then
      print "RX: ";
      print bytesread;
      print " bytes"
   end if
loop

Remarks

Calling this command only makes sense on Avisaro Modules that have some kind of network interface.
Because UDP handles are a limited resource, they must be closed when the channel is no more in use.