-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsdrpp_zeta_tuning.py
61 lines (48 loc) · 1.32 KB
/
sdrpp_zeta_tuning.py
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
58
59
60
import socket
import time
import serial
import serial.tools.list_ports
HOST = 'localhost'
PORT = 4532
ports = serial.tools.list_ports.comports()
device = ""
for info in ports:
print(info.device, info.description, info.manufacturer, info.product, info.serial_number)
if(info.product=="ZetaSDR"):
device = info.device
if(device==""):
print("ZetaSDR nincs csatlakoztatva!")
raise SystemExit
try:
SDR = serial.Serial(device)
except serial.SerialException:
print("Nem lehetett megnyitni a portot:", device)
raise SystemExit
rigctl_client = socket.socket()
try:
rigctl_client.connect((HOST, PORT))
except ConnectionRefusedError:
print('A Rigctl szerver nem elérhető.')
SDR.close()
raise SystemExit
prev_data = 0
while(True):
try:
rigctl_client.sendall(b"f\x0a")
data = rigctl_client.recv(1024)
if(data!=prev_data):
SDR.write(str(int(data)).encode('ascii'))
print(str(int(data)))
out = bytearray()
time.sleep(0.1)
while SDR.inWaiting() > 0:
out.extend(SDR.read())
#print(out.decode())
print(out)
prev_data = data
except Exception as error:
print(error)
break
time.sleep(0.1)
SDR.close()
print('A Rigctl szervert leállították.')