Created
September 23, 2022 01:50
-
-
Save JoelBender/40349dfc93a35944e131ce8494f902c6 to your computer and use it in GitHub Desktop.
Turning on and off pduExpectingReply to follow through the stack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from bacpypes.debugging import btox | |
from bacpypes.pdu import Address, PDU | |
from bacpypes.pdu import PDU | |
from bacpypes.apdu import APDU, ReadPropertyRequest | |
from bacpypes.npdu import NPDU | |
from bacpypes.analysis import decode_packet | |
if "debug" in sys.argv: | |
from bacpypes.consolelogging import ConsoleLogHandler | |
ConsoleLogHandler('bacpypes.apdu', color=3) | |
ConsoleLogHandler('bacpypes.npdu', color=4) | |
# build a request | |
request = ReadPropertyRequest( | |
objectIdentifier=("device", 1), | |
propertyIdentifier="localDate", | |
) | |
request.apduInvokeID = 1 | |
request.apduMaxSegs = 1 | |
request.apduMaxResp = 0x0F | |
request.pduDestination = Address('0x01020304') | |
request.pduNetworkPriority = 0 | |
request.pduExpectingReply = int(sys.argv[1]) | |
if "request" in sys.argv: | |
print("request:") | |
request.debug_contents() | |
print("") | |
# encode as an APDU | |
apdu = APDU() | |
request.encode(apdu) | |
if "apdu" in sys.argv: | |
print("apdu:") | |
apdu.debug_contents() | |
print("") | |
# encode the APDU into an NPDU | |
npdu = NPDU() | |
apdu.encode(npdu) | |
if "npdu" in sys.argv: | |
print("npdu:") | |
npdu.debug_contents() | |
print("") | |
# encode the NPDU into a PDU | |
pdu = PDU() | |
npdu.encode(pdu) | |
print("pdu:") | |
pdu.debug_contents() | |
print("") | |
npdu = NPDU() | |
npdu.decode(pdu) | |
if "npdu" in sys.argv: | |
print("") | |
print("npdu:") | |
npdu.debug_contents() | |
apdu = APDU() | |
apdu.decode(npdu) | |
if "apdu" in sys.argv: | |
print("") | |
print("apdu:") | |
apdu.debug_contents() | |
request = ReadPropertyRequest() | |
request.decode(apdu) | |
if "request" in sys.argv: | |
print("") | |
print("request:") | |
request.debug_contents() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment