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`.
pull/240/head
Niclas Hoyer 2020-01-02 20:57:37 +01:00 committed by Peter Hutterer
parent a0566e0dc0
commit f5ea08f171
1 changed files with 9 additions and 2 deletions

View File

@ -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):
'''