Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange error in apdu.encode(xpdu) #489

Open
mayeranalytics opened this issue May 26, 2023 · 2 comments
Open

Strange error in apdu.encode(xpdu) #489

mayeranalytics opened this issue May 26, 2023 · 2 comments

Comments

@mayeranalytics
Copy link

Hi Joel,

I'm getting a very strange error in apdu.encode(xpdu):

Traceback (most recent call last):
  File "/home/pi/miniconda3/lib/python3.4/site-packages/bacpypes/appservice.py", line 1486, in sap_indication
    apdu.encode(xpdu)
  File "/home/pi/miniconda3/lib/python3.4/site-packages/bacpypes/apdu.py", line 695, in encode
    Sequence.encode(self, self._tag_list)
  File "/home/pi/miniconda3/lib/python3.4/site-packages/bacpypes/constructeddata.py", line 115, in encode
    helper.encode(tag)
  File "/home/pi/miniconda3/lib/python3.4/site-packages/bacpypes/primitivedata.py", line 1810, in encode
    tag.set_app_data(Tag.objectIdentifierAppTag, struct.pack('>L', self.get_long()))
struct.error: argument out of range

get_long returns a number that is too large to pack into ">L" (32 bits).
I have no clue what's going on. Do you have any ideas?

Many thanks

@JoelBender
Copy link
Owner

Inside get_long() is this:

        objType, objInstance = self.get_tuple()

        # pack the components together
        return ((objType << 22) + objInstance)

So this error is (a) the object instance is greater than 4294967295, or (b) the object type is greater than 1023.

@mayeranalytics
Copy link
Author

Yeah.... the dear user switched object instance and object type 🤨 - safety measures added.
Thanks for the pointer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants