From 7e2d240e8524a2832e2858bc16fd5f13b8ec3c19 Mon Sep 17 00:00:00 2001 From: Harry Ho Date: Tue, 15 Sep 2020 15:49:55 +0800 Subject: [PATCH] make stabilizer.py work on v0.4.0+ --- stabilizer.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/stabilizer.py b/stabilizer.py index 0b1e86a..0f1e206 100644 --- a/stabilizer.py +++ b/stabilizer.py @@ -17,11 +17,16 @@ class StabilizerConfig: self.reader, self.writer = await asyncio.open_connection(host, port) async def set(self, channel, iir): - up = OD([("channel", channel), ("iir", iir.as_dict())]) - s = json.dumps(up, separators=(",", ":")) + value = OD([("channel", channel), ("iir", iir.as_dict())]) + request = { + "req": "Write", + "attribute": "stabilizer/iir{}/state".format(channel), + "value": json.dumps(value, separators=[',', ':']).replace('"', "'"), + } + s = json.dumps(request, separators=[',', ':']) assert "\n" not in s logger.debug("send %s", s) - self.writer.write(s.encode() + b"\n") + self.writer.write(s.encode("ascii") + b"\n") r = (await self.reader.readline()).decode() logger.debug("recv %s", r) ret = json.loads(r, object_pairs_hook=OD)