Cleaned the connection and interconnection
This commit is contained in:
parent
02a1bd2fde
commit
5e737f8d55
26
bindings.py
26
bindings.py
|
|
@ -3,6 +3,7 @@
|
|||
################################
|
||||
# IMPORTS
|
||||
# import socketserver
|
||||
|
||||
import socket, threading
|
||||
import sys,time
|
||||
import re
|
||||
|
|
@ -179,11 +180,7 @@ _ALL_MESSAGE_TYPES=[
|
|||
]
|
||||
|
||||
_UPDATE_MSG=[
|
||||
<<<<<<< HEAD
|
||||
"LAYERINP","QUICKFA","QUICKF","TAKE","FREEZE","FREEZEALL","DISPLAYLAYER",
|
||||
=======
|
||||
"LAYERINP","QUICKFA","QUICKF","TAKE","QUICKFA","QUICKF","FREEZE","FREEZEALL","DISPLAYLAYER","DETECTED",
|
||||
>>>>>>> 8d7cf3e793b3cca67e51da6df4ed25c920845d29
|
||||
"LAYERINP","QUICKFA","QUICKF","TAKE","FREEZE","FREEZEALL","DISPLAYLAYER","DETECTED",
|
||||
]
|
||||
# RELOAD_PROGRAM
|
||||
# FREEZE_SCREEN
|
||||
|
|
@ -242,7 +239,6 @@ class analogController(object):
|
|||
eprint('Hostname could not be resolved. Exiting')
|
||||
sys.exit()
|
||||
|
||||
<<<<<<< HEAD
|
||||
def receiveCommand(self,command,*args,**kwargs):
|
||||
"Receive a command froman external source and handle it internally"
|
||||
try:
|
||||
|
|
@ -250,11 +246,10 @@ class analogController(object):
|
|||
except KeyError as e:
|
||||
eprint("The command received {} isn't in the list of supported commands ({})".format(command,self._commandlist))
|
||||
eprint(e)
|
||||
=======
|
||||
|
||||
def addFeedbackInterface(self,feedback):
|
||||
"Add the feedback interface TODO: Several feedback interfaces ?"
|
||||
self.feedback=feedback
|
||||
>>>>>>> 8d7cf3e793b3cca67e51da6df4ed25c920845d29
|
||||
|
||||
def getAttr(self,attribute,default):
|
||||
"A custom attribute fetcher"
|
||||
|
|
@ -438,11 +433,14 @@ class analogController(object):
|
|||
check that the device is ready, by reading the READY status, until it returns the value 1.
|
||||
[*] (* <value>) The controller shall wait and retry until it receives the value 1
|
||||
"""
|
||||
iprint('Connecting to server, {self.ip}:{self.port}'.format(self=self))
|
||||
self.sck.connect((self.ip,self.port))
|
||||
self._connectedLock.release()
|
||||
self.genericSEND("CONNECT","*\r\n")
|
||||
|
||||
try:
|
||||
iprint('Connecting to server, {self.ip}:{self.port}'.format(self=self))
|
||||
self.sck.connect((self.ip,self.port))
|
||||
self._connectedLock.release()
|
||||
self.genericSEND("CONNECT","*\r\n")
|
||||
except ConnectionRefusedError:
|
||||
eprint("Connection to AnalogWay server {self.ip}:{self.port} is impossible".format(self=self))
|
||||
raise ConnectionRefusedError
|
||||
def getDevice(self):
|
||||
"""This read only command gives the device type
|
||||
[?] (DEV <value>) <values>:_DEVICES_VALUES
|
||||
|
|
@ -614,7 +612,7 @@ class analogController(object):
|
|||
self.connect()
|
||||
self.getDevice()
|
||||
self.getVersion()
|
||||
self.getStatus(3)
|
||||
# self.getStatus(3)
|
||||
|
||||
|
||||
#########################################
|
||||
|
|
|
|||
|
|
@ -13,25 +13,14 @@ def sequenceAnswers(s,addr,seq,delay=_DELAY):
|
|||
elt=(elt).encode()
|
||||
resps=[(i+"\r\n").encode() for i in resps]
|
||||
print("[{}] Waiting for {}".format(name,elt))
|
||||
<<<<<<< HEAD
|
||||
while recv!=elt and recv:
|
||||
=======
|
||||
while recv not in elt:
|
||||
>>>>>>> 8d7cf3e793b3cca67e51da6df4ed25c920845d29
|
||||
recv=s.recv(4095)
|
||||
print("[{}] Received : {}".format(name,recv))
|
||||
for r in resps:
|
||||
print("[{}] Sending : {}".format(name,r))
|
||||
time.sleep(delay)
|
||||
s.sendall(r)
|
||||
<<<<<<< HEAD
|
||||
while True:
|
||||
recv=s.recv(4096)
|
||||
if not recv:
|
||||
break
|
||||
print(recv.decode())
|
||||
=======
|
||||
>>>>>>> 8d7cf3e793b3cca67e51da6df4ed25c920845d29
|
||||
|
||||
except ConnectionResetError as e:
|
||||
print("[{}] Has stopped the connection".format(name))
|
||||
print(e)
|
||||
|
|
|
|||
Loading…
Reference in New Issue