diff options
author | Chris Liechti <cliechti@gmx.net> | 2016-05-23 22:35:06 +0200 |
---|---|---|
committer | Chris Liechti <cliechti@gmx.net> | 2016-05-23 22:35:06 +0200 |
commit | 35f927dc4bde98acfeb469da386526345d94b671 (patch) | |
tree | 8170451404051bba302550dc4a776b335147508b | |
parent | a83408ad5009976495ebecefa0be3193d2f84fa3 (diff) | |
download | pyserial-git-35f927dc4bde98acfeb469da386526345d94b671.tar.gz |
asyncio: use serial_for_url, improve test end
-rw-r--r-- | serial/aio.py | 5 |
1 files changed, 3 insertions, 2 deletions
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 @@ class SerialTransport(asyncio.Transport): @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 @@ if __name__ == '__main__': 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') |