JoelBender / bacpypes

BACpypes provides a BACnet application layer and network layer written in Python for daemons, scripting, and graphical interfaces.
MIT License
296 stars 129 forks source link

segmentationNotSupported #397

Open anas-rz opened 3 years ago

anas-rz commented 3 years ago

Hi @JoelBender ,

Hope you are doing great.

I am reading data from AHUs but while fetching the list of objects it gives an error: segmentationNotSupported. On sending WhoIsIAm, I get this response:

Device Address        = <RemoteStation 4100:9>
Device Id             = 409
maxAPDULengthAccepted = 206
segmentationSupported = noSegmentation
vendorID              = 17

The configurations for my client application are:

[BACpypes]
objectName: Betelgeuse
address: myIP/24
objectIdentifier: 599
maxApduLengthAccepted: 206 
segmentationSupported: segmentedBoth
vendorIdentifier: 15

I changed the maxApduLengthAccepted to that of remote device. Also tried to make it large enough for other devices. Read other issues tried debugging

python read.py --debug bacpypes.appservice.ClientSSM
DEBUG:bacpypes.consolelogging.ConfigArgumentParser:__init__
DEBUG:bacpypes.consolelogging.ArgumentParser:__init__
DEBUG:bacpypes.consolelogging.ConfigArgumentParser:update_os_env
DEBUG:bacpypes.consolelogging.ArgumentParser:update_os_env
DEBUG:bacpypes.consolelogging.ArgumentParser:    - settings: {'debug_file': '', 'debug': set([]), 'max_bytes': 1048576, 'color': False, 'backup_count': 5, 'route_aware': False}
DEBUG:bacpypes.consolelogging.ArgumentParser:    - os environment
DEBUG:bacpypes.consolelogging.ArgumentParser:parse_args
DEBUG:bacpypes.consolelogging.ConfigArgumentParser:expand_args Namespace(buggers=False, color=None, debug=['bacpypes.appservice.ClientSSM'], ini='BACpypes.ini', route_aware=None)
DEBUG:bacpypes.consolelogging:    - config: <ConfigParser.ConfigParser instance at 0x7fa5066dc0>
DEBUG:bacpypes.consolelogging:    - ini_obj: {'objectidentifier': '599', 'segmentationsupported': 'segmentedReceive', 'objectname': 'Betelgeuse', 'address': 'myIP/24', 'vendoridentifier': '15', 'maxapdulengthaccepted': '206'}
DEBUG:bacpypes.consolelogging.ArgumentParser:expand_args Namespace(buggers=False, color=None, debug=['bacpypes.appservice.ClientSSM'], ini={'objectidentifier': '599', 'segmentationsupported': 'segmentedReceive', 'objectname': 'Betelgeuse', 'address': 'myIP/24', 'vendoridentifier': '15', 'maxapdulengthaccepted': '206'}, route_aware=None)
DEBUG:bacpypes.consolelogging.ArgumentParser:    - debug: ['bacpypes.appservice.ClientSSM']
DEBUG:bacpypes.consolelogging.ArgumentParser:    - color not specified
DEBUG:bacpypes.consolelogging.ArgumentParser:    - route_aware not specified
DEBUG:bacpypes.consolelogging.ArgumentParser:    - args expanded
DEBUG:bacpypes.consolelogging.ArgumentParser:interpret_debugging Namespace(buggers=False, color=None, debug=['bacpypes.appservice.ClientSSM'], ini={'objectidentifier': '599', 'segmentationsupported': 'segmentedReceive', 'objectname': 'Betelgeuse', 'address': 'myIP/24', 'vendoridentifier': '15', 'maxapdulengthaccepted': '206'}, route_aware=None)
DEBUG:bacpypes.consolelogging.ArgumentParser:    - settings: {'debug_file': '', 'debug': set(['bacpypes.appservice.ClientSSM']), 'max_bytes': 1048576, 'ini': 'BACpypes.ini', 'color': False, 'backup_count': 5, 'route_aware': False}
DEBUG:bacpypes.consolelogging.ArgumentParser:    - interpreted debugging
> read 4100:9 device:409 objectList 
DEBUG:bacpypes.appservice.ClientSSM:__init__ <bacpypes.appservice.StateMachineAccessPoint object at 0x7fa50736d0> <Address 4100:9>
DEBUG:bacpypes.appservice.ClientSSM:indication <bacpypes.apdu.ConfirmedRequestPDU(12,1) instance at 0x7fa5073ed0>
    <bacpypes.apdu.ConfirmedRequestPDU(12,1) instance at 0x7fa5073ed0>
        pduDestination = <Address 4100:9>
        pduExpectingReply = 1
        pduNetworkPriority = 0
        apduType = 0
        apduService = 12
        apduInvokeID = 1
        pduData = x'0c.02.00.10.71.19.4c'
DEBUG:bacpypes.appservice.ClientSSM:    - segment size: 206
DEBUG:bacpypes.appservice.ClientSSM:    - invoke ID: 1
DEBUG:bacpypes.appservice.ClientSSM:    - segment count: 1
DEBUG:bacpypes.appservice.ClientSSM:set_state 2 (AWAIT_CONFIRMATION) timer=3000
DEBUG:bacpypes.appservice.ClientSSM:request <bacpypes.apdu.ConfirmedRequestPDU(12,1) instance at 0x7fa50733d0>
    <bacpypes.apdu.ConfirmedRequestPDU(12,1) instance at 0x7fa50733d0>
        pduDestination = <Address 4100:9>
        pduExpectingReply = 1
        pduNetworkPriority = 0
        apduType = 0
        apduSeg = False
        apduMor = False
        apduSA = True
        apduMaxSegs = 4
        apduMaxResp = 2
        apduService = 12
        apduInvokeID = 1
        pduData = x'0c.02.00.10.71.19.4c'
DEBUG:bacpypes.appservice.ClientSSM:confirmation <bacpypes.apdu.AbortPDU(None,1) instance at 0x7fa51ab650>
    <bacpypes.apdu.AbortPDU(None,1) instance at 0x7fa51ab650>
        pduSource = <RemoteStation 4100:9>
        pduDestination = <Address myIP>
        pduExpectingReply = False
        pduNetworkPriority = 0
        apduType = 7
        apduSrv = True
        apduInvokeID = 1
        apduAbortRejectReason = 4
        pduData = x''
DEBUG:bacpypes.appservice.ClientSSM:await_confirmation <bacpypes.apdu.AbortPDU(None,1) instance at 0x7fa51ab650>
    <bacpypes.apdu.AbortPDU(None,1) instance at 0x7fa51ab650>
        pduSource = <RemoteStation 4100:9>
        pduDestination = <Address myIP>
        pduExpectingReply = False
        pduNetworkPriority = 0
        apduType = 7
        apduSrv = True
        apduInvokeID = 1
        apduAbortRejectReason = 4
        pduData = x''
DEBUG:bacpypes.appservice.ClientSSM:    - server aborted
DEBUG:bacpypes.appservice.ClientSSM:set_state 7 (ABORTED) timer=0
DEBUG:bacpypes.appservice.ClientSSM:    - remove from active transactions
DEBUG:bacpypes.appservice.ClientSSM:response <bacpypes.apdu.AbortPDU(None,1) instance at 0x7fa51ab650>
    <bacpypes.apdu.AbortPDU(None,1) instance at 0x7fa51ab650>
        pduSource = <RemoteStation 4100:9>
        pduDestination = <Address myIP>
        pduExpectingReply = False
        pduNetworkPriority = 0
        apduType = 7
        apduSrv = True
        apduInvokeID = 1
        apduAbortRejectReason = 4
        pduData = x''
segmentationNotSupported

Also tried to make APDU length large enough and equal to that of remote device but still couldn't read objectList. I am able to read individual properties and their values but not overall list of objects. Can I read it? I need to put them in @volttron for grab_bacnet_config.py script. Is there a way around to tweak the apdu length or segmentation stuff?

Regards, Muhammad Anas Raza

JoelBender commented 3 years ago

If you are getting a segmentation not supported error from the device then chances are it is not you as a client that doesn't have a big enough maxApduLengthAccepted value, it's the device. Even though the property name is objectList it is a BACnet array, so break your request into pieces. Reading array index 0 returns the number of elements in the list, then cycle through that value and read each array element one at a time.

The only time this doesn't work is for properties like the deviceAddressBinding which is a list, do you can read the whole thing or nothing at all.