-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathudpclient.py
More file actions
executable file
·49 lines (40 loc) · 795 Bytes
/
udpclient.py
File metadata and controls
executable file
·49 lines (40 loc) · 795 Bytes
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# * UDP modifications: Original Code by Olgierd Pilarczyk
# * Extended by Frederik Granna <rtlsdr@granna.de>
#
import socket, sys
if len(sys.argv) < 3:
sys.exit(3)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("localhost", 6020))
buf = ""
mode = sys.argv[1]
data = sys.argv[2]
if mode == 'freq':
buf = buf + chr(0)
elif mode == 'mode':
buf = buf + chr(1)
elif mode == 'squelch':
buf = buf + chr(2)
elif mode == 'gain':
buf = buf + chr(3)
if data == 'auto':
data = -100
elif mode == 'agc':
buf = buf + chr(8)
if data == 'on':
data = 1
elif data == 'off':
data = 0
else:
sys.exit(1)
data = int(data)
i=0
while i < 4:
buf = buf + chr(data & 0xff)
data = data >> 8
i = i + 1
s.send(buf)
s.close()