asyncio: use serial_for_url, improve test end
diff --git a/serial/aio.py b/serial/aio.py
index 3ba12d2..b3238db 100644
--- a/serial/aio.py
+++ b/serial/aio.py
@@ -356,7 +356,7 @@
@asyncio.coroutine
def create_serial_connection(loop, protocol_factory, *args, **kwargs):
- ser = serial.Serial(*args, **kwargs)
+ ser = serial.serial_for_url(*args, **kwargs)
protocol = protocol_factory()
transport = SerialTransport(loop, protocol, ser)
return (transport, protocol)
@@ -404,7 +404,8 @@
def data_received(self, data):
print('data received', repr(data))
- self.transport.close()
+ if b'\n' in data:
+ self.transport.close()
def connection_lost(self, exc):
print('port closed')