mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 13:17:50 +02:00
Refactor net-to-serial.py to support JMRI
This commit is contained in:
@@ -18,9 +18,12 @@ class SerialDaemon:
|
||||
pass
|
||||
|
||||
async def handle_echo(self, reader, writer):
|
||||
while 1: # keep connection to client open
|
||||
data = await reader.read(100)
|
||||
addr = writer.get_extra_info('peername')
|
||||
if not data: # client has disconnected
|
||||
break
|
||||
|
||||
addr = writer.get_extra_info('peername')
|
||||
logging.info("Received {} from {}".format(data, addr[0]))
|
||||
|
||||
self.ser.write(data)
|
||||
@@ -33,8 +36,8 @@ class SerialDaemon:
|
||||
writer.write(response)
|
||||
await writer.drain()
|
||||
|
||||
logging.info("Close the connection")
|
||||
writer.close()
|
||||
await writer.wait_closed()
|
||||
|
||||
async def return_board(self):
|
||||
self.ser.write(b'<s>')
|
||||
|
Reference in New Issue
Block a user