Initialisation

This commit is contained in:
Maximilien Rigaut 2021-09-30 19:37:04 +02:00
parent 7777a02d97
commit 3633d85728
2 changed files with 33 additions and 3 deletions

View File

@ -149,7 +149,7 @@ class analogController(object):
self.sendData('#{}'.format(value))
ret=self.waitfor(_WAIT_STATUS)
print(ret)
def _keepAlive(self,val=1):
"""Send a keepalive to check (and ensure) the connection is still up
[<val1>SYpig] Will return the invert of the value sent: 0x0000 0000 will return 0xFFFF FFFF
@ -268,11 +268,11 @@ class analogController(object):
#####################
# TESTING
if __name__ == '__main__':
_HOSTS=[["127.0.0.1",10500]] # Test server
ctrl1=analogController(*_HOSTS[0])
ctrl1.connectionSequence()
ctrl1.waitfor("")
# ctrl1.waitfor("")
# except ConnectionRefusedError:
# # Receive data
# print('# Receive data from server')

30
falseserver.py Normal file
View File

@ -0,0 +1,30 @@
def sequenceAnswers(seq):
def Main():
host = "127.0.0.1"
# reverse a port on your computer
# in our case it is 12345 but it
# can be anything
port = 10500
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((host, port))
print("socket binded to port", port)
# put the socket into listening mode
s.listen(5)
print("socket is listening")
# a forever loop until client wants to exit
while True:
# establish connection with client
c, addr = s.accept()
# Start a new thread and return its identifier
start_new_thread(sequenceAnswers, (sequence,))
s.close()
if __name__ == '__main__':
Main()