1
0
mirror of https://github.com/JoelBender/bacpypes synced 2025-09-28 22:15:23 +08:00

change all the signed octet pack/unpack to unsigned

This commit is contained in:
Joel Bender 2015-08-02 23:12:58 -04:00
parent 263853760c
commit 9c8ec37938
8 changed files with 28 additions and 28 deletions

View File

@ -83,7 +83,7 @@ class Address:
if (addr < 0) or (addr >= 256):
raise ValueError("address out of range")
self.addrAddr = struct.pack('b', addr)
self.addrAddr = struct.pack('B', addr)
self.addrLen = 1
elif isinstance(addr, str):
@ -133,7 +133,7 @@ class Address:
if (addr > 255):
raise ValueError("address out of range")
self.addrAddr = struct.pack('b', addr)
self.addrAddr = struct.pack('B', addr)
self.addrLen = 1
elif re.match(r"^\d+:[*]$", addr):
@ -161,7 +161,7 @@ class Address:
self.addrType = Address.remoteStationAddr
self.addrNet = net
self.addrAddr = struct.pack('b', addr)
self.addrAddr = struct.pack('B', addr)
self.addrLen = 1
elif re.match(r"^0x([0-9A-Fa-f][0-9A-Fa-f])+$",addr):
@ -337,17 +337,17 @@ class LocalStation(Address):
if (addr < 0) or (addr >= 256):
raise ValueError("address out of range")
self.addrAddr = struct.pack('b', addr)
self.addrAddr = struct.pack('B', addr)
self.addrLen = 1
elif isinstance(addr, (bytes, bytearray)):
if _debug: Address._debug(" - bytes or bytearray")
elif isinstance(addr, str):
if _debug: Address._debug(" - string (bytes)")
self.addrAddr = bytes(addr)
self.addrAddr = addr
self.addrLen = len(addr)
else:
raise TypeError("integer, bytes or bytearray required")
raise TypeError("integer or string (bytes) required")
#
# RemoteStation
@ -366,17 +366,17 @@ class RemoteStation(Address):
if (addr < 0) or (addr >= 256):
raise ValueError("address out of range")
self.addrAddr = struct.pack('b', addr)
self.addrAddr = struct.pack('B', addr)
self.addrLen = 1
elif isinstance(addr, (bytes, bytearray)):
if _debug: Address._debug(" - bytes or bytearray")
elif isinstance(addr, str):
if _debug: Address._debug(" - string (bytes)")
self.addrAddr = bytes(addr)
self.addrAddr = addr
self.addrLen = len(addr)
else:
raise TypeError("integer, bytes or bytearray required")
raise TypeError("integer or string (bytes) required")
#
# LocalBroadcast

View File

@ -189,7 +189,7 @@ class Tag(object):
# context booleans have value in data
if (dataType == Tag.booleanAppTag):
return Tag(Tag.applicationTagClass, Tag.booleanAppTag, struct.unpack('b', self.tagData)[0], '')
return Tag(Tag.applicationTagClass, Tag.booleanAppTag, struct.unpack('B', self.tagData)[0], '')
else:
return ApplicationTag(dataType, self.tagData)

View File

@ -141,7 +141,7 @@ class UDPMultiplexer:
return
# extract the first octet
msg_type = struct.unpack('b', pdu.pduData[:1])[0]
msg_type = struct.unpack('B', pdu.pduData[:1])[0]
# check for the message type
if msg_type == 0x01:

View File

@ -84,7 +84,7 @@ class Address:
if (addr < 0) or (addr >= 256):
raise ValueError("address out of range")
self.addrAddr = struct.pack('b', addr)
self.addrAddr = struct.pack('B', addr)
self.addrLen = 1
elif isinstance(addr, str):
@ -134,7 +134,7 @@ class Address:
if (addr > 255):
raise ValueError("address out of range")
self.addrAddr = struct.pack('b', addr)
self.addrAddr = struct.pack('B', addr)
self.addrLen = 1
elif re.match(r"^\d+:[*]$", addr):
@ -162,7 +162,7 @@ class Address:
self.addrType = Address.remoteStationAddr
self.addrNet = net
self.addrAddr = struct.pack('b', addr)
self.addrAddr = struct.pack('B', addr)
self.addrLen = 1
elif re.match(r"^0x([0-9A-Fa-f][0-9A-Fa-f])+$",addr):
@ -336,7 +336,7 @@ class LocalStation(Address):
if (addr < 0) or (addr >= 256):
raise ValueError("address out of range")
self.addrAddr = struct.pack('b', addr)
self.addrAddr = struct.pack('B', addr)
self.addrLen = 1
elif isinstance(addr, (bytes, bytearray)):
@ -365,7 +365,7 @@ class RemoteStation(Address):
if (addr < 0) or (addr >= 256):
raise ValueError("address out of range")
self.addrAddr = struct.pack('b', addr)
self.addrAddr = struct.pack('B', addr)
self.addrLen = 1
elif isinstance(addr, (bytes, bytearray)):

View File

@ -189,7 +189,7 @@ class Tag(object):
# context booleans have value in data
if (dataType == Tag.booleanAppTag):
return Tag(Tag.applicationTagClass, Tag.booleanAppTag, struct.unpack('b', self.tagData)[0], b'')
return Tag(Tag.applicationTagClass, Tag.booleanAppTag, struct.unpack('B', self.tagData)[0], b'')
else:
return ApplicationTag(dataType, self.tagData)

View File

@ -141,7 +141,7 @@ class UDPMultiplexer:
return
# extract the first octet
msg_type = struct.unpack('b', pdu.pduData[:1])[0]
msg_type = struct.unpack('B', pdu.pduData[:1])[0]
# check for the message type
if msg_type == 0x01:

View File

@ -84,7 +84,7 @@ class Address:
if (addr < 0) or (addr >= 256):
raise ValueError("address out of range")
self.addrAddr = struct.pack('b', addr)
self.addrAddr = struct.pack('B', addr)
self.addrLen = 1
elif isinstance(addr, (bytes, bytearray)):
@ -150,7 +150,7 @@ class Address:
if (addr > 255):
raise ValueError("address out of range")
self.addrAddr = struct.pack('b', addr)
self.addrAddr = struct.pack('B', addr)
self.addrLen = 1
elif re.match(r"^\d+:[*]$", addr):
@ -178,7 +178,7 @@ class Address:
self.addrType = Address.remoteStationAddr
self.addrNet = net
self.addrAddr = struct.pack('b', addr)
self.addrAddr = struct.pack('B', addr)
self.addrLen = 1
elif re.match(r"^0x([0-9A-Fa-f][0-9A-Fa-f])+$",addr):
@ -351,7 +351,7 @@ class LocalStation(Address):
if (addr < 0) or (addr >= 256):
raise ValueError("address out of range")
self.addrAddr = struct.pack('b', addr)
self.addrAddr = struct.pack('B', addr)
self.addrLen = 1
elif isinstance(addr, (bytes, bytearray)):
@ -380,7 +380,7 @@ class RemoteStation(Address):
if (addr < 0) or (addr >= 256):
raise ValueError("address out of range")
self.addrAddr = struct.pack('b', addr)
self.addrAddr = struct.pack('B', addr)
self.addrLen = 1
elif isinstance(addr, (bytes, bytearray)):

View File

@ -189,7 +189,7 @@ class Tag(object):
# context booleans have value in data
if (dataType == Tag.booleanAppTag):
return Tag(Tag.applicationTagClass, Tag.booleanAppTag, struct.unpack('b', self.tagData)[0], b'')
return Tag(Tag.applicationTagClass, Tag.booleanAppTag, struct.unpack('B', self.tagData)[0], b'')
else:
return ApplicationTag(dataType, self.tagData)