From f5ea08f1710fcb59679baf3b81dae5217c3e7005 Mon Sep 17 00:00:00 2001 From: Niclas Hoyer Date: Thu, 2 Jan 2020 20:57:37 +0100 Subject: [PATCH] Add support for long device names If the device name is longer than one reply, the registration will crash. This adds support for a variable number of replies until the reply ends with `0x0a`. --- tuhi/protocol.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tuhi/protocol.py b/tuhi/protocol.py index 5c0d982..f618bff 100644 --- a/tuhi/protocol.py +++ b/tuhi/protocol.py @@ -651,11 +651,18 @@ class MsgGetName(Msg): opcode = 0xbb protocol = ProtocolVersion.ANY + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.name = "" + def _handle_reply(self, reply): if reply.opcode != 0xbc: raise UnexpectedReply(f'Unknown reply: {reply.opcode}') - self.name = bytes(reply).decode('utf-8') - + self.name += bytes(reply).decode('utf-8') + if bytes(reply)[-1] != 0x0a: + self.requires_request = False + self.execute() + self.requires_request = True class MsgGetNameIntuosPro(Msg): '''