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