EasyManua.ls Logo

TDT RZ2 - Page 93

TDT RZ2
736 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
System 3 1-87
RZ-UDP Communications Interface
# configure the header. Notice that it includes the
header
# information followed by the command 2 (set remote IP)
# and 0 (no data packets for header).
packet = struct.pack('4B', 0x55, 0xAA, CMD_SET_REMOTE_IP,
0)
# Sends the packet to the UDP interface, setting the
remote IP
# address of the UDP interface to the host PC
sock.send(packet)
The code above simply sends a command packet to the UDP interface listening Port
(22022) and tells it to set the UDP interface remote IP to the host PC IP
address. Once this has been done, any data packets sent by the UDP Ethernet
interface will go to this IP address.
Note: The listening port on the UDP Ethernet interface is 22022 and cannot be changed.
The code structure below is necessary to receive a packet from the UDP interface:
while 1:
# Receive a data packet from the UDP interface
packet = sock.recv(1024)
# Process received packet
# ...
The code structure below is necessary to send a packet of 16 channels to the UDP
interface:
# begin sending data
NPACKETS = 16
# configure the header. Notice that the command is now 0
# (sending data packets) and the number of packets
following is 16
header = struct.pack('4B', 0x55, 0xAA, CMD_SEND_DATA,
NPACKETS)
count = 0
while 1:
# this example uses fake data
fakeval = count % 10
data = range(fakeval, NPACKETS + fakeval)
# append sixteen 32-bit words to the header
# '>' in the format string is used to force big-endian

Table of Contents

Related product manuals