bugfix
This commit is contained in:
parent
6894c7fb3a
commit
1b3325f2e6
@ -28,7 +28,10 @@ class UdpComm:
|
|||||||
def run(self):
|
def run(self):
|
||||||
sock = self.udpSerSock
|
sock = self.udpSerSock
|
||||||
while self.run_flg:
|
while self.run_flg:
|
||||||
in_s, out_s, exc_s = select([sock], [sock], [])
|
outs = []
|
||||||
|
if len(self.buffer) > 0:
|
||||||
|
outs = [sock]
|
||||||
|
in_s, out_s, exc_s = select([sock], outs, [], 0.1)
|
||||||
if sock in in_s:
|
if sock in in_s:
|
||||||
b, addr = sock.recvfrom(BUFSIZE)
|
b, addr = sock.recvfrom(BUFSIZE)
|
||||||
t = b[0]
|
t = b[0]
|
||||||
@ -36,17 +39,27 @@ class UdpComm:
|
|||||||
if t == 'b':
|
if t == 'b':
|
||||||
self.callback(b, addr)
|
self.callback(b, addr)
|
||||||
else:
|
else:
|
||||||
txt = b.decode('utf-8')
|
try:
|
||||||
d = json.loads(txt)
|
txt = b.decode('utf-8')
|
||||||
self.callback(d, addr)
|
d = json.loads(txt)
|
||||||
|
self.callback(d, addr)
|
||||||
|
except Exception as e:
|
||||||
|
print('except:',e)
|
||||||
|
print_exc()
|
||||||
|
print(t, b)
|
||||||
|
break
|
||||||
if sock in out_s:
|
if sock in out_s:
|
||||||
while len(self.buffer) > 0:
|
while len(self.buffer) > 0:
|
||||||
d,addr = self.buffer.pop(0)
|
d,addr = self.buffer.pop(0)
|
||||||
sock.sendto(d, addr)
|
sock.sendto(d, addr)
|
||||||
|
time.sleep(0.1)
|
||||||
|
self.run_flg = False
|
||||||
self.udpSerSock.close()
|
self.udpSerSock.close()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.run_flg = False
|
self.run_flg = False
|
||||||
|
self.udpSerSock.close()
|
||||||
|
self.thread.join()
|
||||||
|
|
||||||
def broadcast(self, data):
|
def broadcast(self, data):
|
||||||
broadcast_host = '.'.join(self.host.split('.')[:-1]) + '.255'
|
broadcast_host = '.'.join(self.host.split('.')[:-1]) + '.255'
|
||||||
|
@ -1 +1 @@
|
|||||||
__version__ = '5.1.24'
|
__version__ = '5.1.25'
|
||||||
|
Loading…
Reference in New Issue
Block a user