Last active
November 20, 2017 07:27
-
-
Save darksidelemm/2a1fb385f6fc18566f3bcf29b4929053 to your computer and use it in GitHub Desktop.
fake rigctld, for recording sat frequency data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Fake rigctld listener. | |
# Hacked together in 10 minutes. | |
# | |
# Mark Jessop <[email protected]> | |
# | |
import socket | |
import datetime | |
HOST = '' | |
PORT = 4532 # Arbitrary non-privileged port | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.bind((HOST, PORT)) | |
s.listen(1) | |
conn, addr = s.accept() | |
print 'Connected by', addr | |
freq = 144000000 | |
f = open("frequency.log",'w') | |
while 1: | |
data = conn.recv(512) | |
if not data: | |
break | |
if data[0] == 'F': | |
#print(data) | |
freq = int(data.split(' ')[1]) | |
conn.sendall("RPRT 0\n") | |
timestamp = datetime.datetime.utcnow().isoformat() | |
log_data = "%s,%d\n" % (timestamp,freq) | |
f.write(log_data) | |
f.flush() | |
print("%s,%d" % (timestamp,freq)) | |
elif data[0] == 'f': | |
conn.sendall("f %d\n" % freq) | |
else: | |
conn.sendall("RPRT 0\n") | |
conn.close() | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment