Send bytes

spacecruft
Jeff Moe 2022-10-01 15:06:40 -06:00
parent 6273be3743
commit bb918be492
1 changed files with 9 additions and 9 deletions

View File

@ -146,7 +146,7 @@ class TCPServer(object):
# "\\dump_state" is sent by satnogs hamlib, need to ignore it and send okay state
if cmd == '\\dump_state':
fd.send('RPRT 0\n')
fd.send(b'RPRT 0\n')
return
print('<-- %s' % repr(cmd))
@ -160,7 +160,7 @@ class TCPServer(object):
if cmd == 'S':
self.rotor.stop()
print('--> RPRT 0')
fd.send('RPRT 0\n')
fd.send(b'RPRT 0\n')
return
# "p", to get current position
@ -168,11 +168,11 @@ class TCPServer(object):
pos = self.rotor.get_pos()
if not pos:
print('--> RPRT -6')
fd.send('RPRT -6\n')
fd.send(b'RPRT -6\n')
else:
az, el = pos
print('--> %d,%d' % (az, el))
fd.send('%.6f\n%.6f\n' % (az, el))
fd.send(b'%.6f\n%.6f\n' % (az, el))
return
# "P <az> <el>" to set desired position
@ -185,7 +185,7 @@ class TCPServer(object):
el = int(float(el))
except:
print('--> RPRT -8 (could not parse)')
fd.send('RPRT -8\n')
fd.send(b'RPRT -8\n')
return
if az == 360:
@ -193,22 +193,22 @@ class TCPServer(object):
if az > 359:
print('--> RPRT -1 (az too large)')
fd.send('RPRT -1\n')
fd.send(b'RPRT -1\n')
return
if el > 90:
print('--> RPRT -1 (el too large)')
fd.send('RPRT -1\n')
fd.send(b'RPRT -1\n')
return
self.rotor.set_pos(az, el)
print('--> RPRT 0')
fd.send('RPRT 0\n')
fd.send(b'RPRT 0\n')
return
# Nothing else is supported
print('--> RPRT -4 (unknown command)')
fd.send('RPRT -4\n')
fd.send(b'RPRT -4\n')
def read_client(self, fd):
buf = fd.recv(1024)