mirror of
https://github.com/undera/pylgbst.git
synced 2020-11-18 19:37:26 -08:00
Accept also bytearray type for message (#29)
This commit is contained in:
parent
32eecac1a6
commit
02d1ca0188
@ -58,7 +58,7 @@ class UpstreamMsg(Message):
|
||||
assert hub_id == 0
|
||||
msg_type = msg._byte()
|
||||
assert cls.TYPE == msg_type, "Message type does not match: %x!=%x" % (cls.TYPE, msg_type)
|
||||
assert isinstance(msg.payload, bytes)
|
||||
assert isinstance(msg.payload, (bytes, bytearray))
|
||||
return msg
|
||||
|
||||
def __shift(self, vtype, vlen):
|
||||
|
@ -30,7 +30,7 @@ def usint(seq, index):
|
||||
def str2hex(data): # we need it for python 2+3 compatibility
|
||||
# if sys.version_info[0] == 3:
|
||||
# data = bytes(data, 'ascii')
|
||||
if not isinstance(data, bytes):
|
||||
if not isinstance(data, (bytes, bytearray)):
|
||||
data = bytes(data, 'ascii')
|
||||
hexed = binascii.hexlify(data)
|
||||
return hexed
|
||||
|
Loading…
x
Reference in New Issue
Block a user