Skip to content
This repository has been archived by the owner on Oct 14, 2022. It is now read-only.

Commit

Permalink
shutter: cr-lf line ending
Browse files Browse the repository at this point in the history
  • Loading branch information
jordens committed Jul 27, 2018
1 parent 8c181db commit 22e3355
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions ptb/shutter_protocol.py
Expand Up @@ -35,7 +35,7 @@ async def status(self):
Returns:
list(float): Temperatures on all channels
"""
ret = (await self.ask(b"e", 3)).strip()
ret = (await self.ask(b"e")).strip()
return tuple(bool(int(_)) for _ in ret)

def clear(self):
Expand All @@ -52,4 +52,4 @@ async def passthrough(self, shutter, cmd):
Return:
bytes: Response
"""
return await self.ask("{:d}".encode() + cmd)
return await self.ask(bytes(["{:d}".format(shutter).encode(), cmd]))
7 changes: 3 additions & 4 deletions ptb/shutter_tcp.py
Expand Up @@ -5,7 +5,7 @@

class ShutterTCP(ShutterProtocol):
eol_write = b"\r\n"
eol_read = b"\r"
eol_read = b"\r\n"

def __init__(self, reader, writer):
self._reader = reader
Expand All @@ -29,9 +29,8 @@ def _writeline(self, cmd):
self._writer.write(cmd + self.eol_write)

async def _readline(self):
r = b""
while not r.endswith(self.eol_read):
r += await self._reader.read(1)
r = await self._reader.readline()
assert r.endswith(self.eol_read)
return r[:-len(self.eol_read)]

async def _read(self, n):
Expand Down

0 comments on commit 22e3355

Please sign in to comment.