fix communication with new board messages etc
This commit is contained in:
parent
4d21ebb78e
commit
6a35c6767b
5 changed files with 14 additions and 15 deletions
|
@ -86,8 +86,8 @@ class SimpleFormat(BaseFormat):
|
|||
|
||||
|
||||
class EnumFormat(SimpleFormat):
|
||||
def __init__(self, as_hex=False):
|
||||
super().__init__("B")
|
||||
def __init__(self, fmt="B", *, as_hex=False):
|
||||
super().__init__(fmt)
|
||||
self.as_hex = as_hex
|
||||
|
||||
def set_field_type(self, field_type):
|
||||
|
@ -210,12 +210,11 @@ class VarArrayFormat(BaseVarFormat):
|
|||
|
||||
|
||||
class VarStrFormat(BaseVarFormat):
|
||||
|
||||
def get_var_num(self):
|
||||
return 1
|
||||
|
||||
def encode(self, value: str) -> bytes:
|
||||
return struct.pack(self.num_fmt, len(str)) + value.encode()
|
||||
return struct.pack(self.num_fmt, len(value)) + value.encode()
|
||||
|
||||
def decode(self, data: bytes) -> tuple[str, bytes]:
|
||||
num = struct.unpack(self.num_fmt, data[:self.num_size])[0]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue