client_channel_serial.py
1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
"""SERIAL Client implementation
"""
# Standard library imports
# Third party imports
# None
# Local application imports
from devices_channel.client.client_channel import *
class ClientChannelSerial(ClientChannel):
buf = 1024
def __init__(self, server_host:str="localhost", server_port:int=11110, buffer_size=1024, DEBUG:bool=False):
'''
:param server_host: server IP or hostname
:param server_port: server port
'''
#TODO: set a protocol
self.protocol = None
super().__init__(server_host, server_port, "SERIAL", buffer_size, DEBUG)
#@override
def _connect_to_server(self):
pass
# Close socket
def close(self):
self.mysock.close()
#@override
def _send_data(self, data_to_send:str):
pass
#@override
def _receive_data(self)->str:
data_received = self.mysock.recv(self.buf)
return data_received