-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrx_data_config.py
More file actions
57 lines (44 loc) · 1.23 KB
/
rx_data_config.py
File metadata and controls
57 lines (44 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#///////////////////////////////////////////////////////////////////////////////
#//
#// Script to transmit data.
#//
#// In terminal window (an example):
#//
#// $ rxdata.py <ip_address> [port]
#//
#////////////////////////////////////////////////////////////////////////////////
from unetpy import *
import sys
port = 1100
ip_address = 'localhost'
if (len(sys.argv) < 2):
print("Usage : rxdata <ip_address> <rx_node_address> <port> \n"
"ip_address: IP address of the transmitter modem. \n"
"port: port number of transmitter modem. \n"
"A usage example: \n"
"rxdata.py 192.168.1.20 1100\n");
sys.exit();
ip_address = sys.argv[1]
if (len(sys.argv) > 2):
port = int(sys.argv[2])
print("Connecting to " + ip_address + ":" + str(port));
sock = UnetSocket(ip_address, port)
if ( sock == None ):
print("Couldn't open unet socket");
sys.exit();
# Bind to protocol DATA
if (not sock.bind(Protocol.DATA)):
print("Couldn't open bind to socket");
sys.exit();
# Set a timeout of 10 seconds
sock.setTimeout(10000);
# Receive and display data
print("Waiting for a Datagram");
ntf = sock.receive()
if (ntf != None):
print(ntf)
else:
print("Error receiving data")
# Close the unet socket
sock.close()
print("Reception Complete");