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

Two small changes to be able to talk to a Johnson Controls NCE #238

Merged

Conversation

gnmerritt
Copy link
Contributor

Docs for the device here: https://cgproducts.johnsoncontrols.com/met_pdf/1201531.pdf?ref=binfind.com/web

Explanations in the commit messages, needed both to be able to consistently talk to a (probably overloaded) controller device

this prevents a ton of unused property read requests especially for
controllers with a large number of points
If you do, you'll end up with an InvalidTag exception getting thrown
by baypypes.primitivedata:

Traceback (most recent call last):
  File "... lib/python3.8/site-packages/BAC0/core/devices/Points.py", line 195, in update_bacnet_properties
    res = self.properties.device.properties.network.readMultiple(
  File "... lib/python3.8/site-packages/BAC0/core/io/Read.py", line 353, in readMultiple
    value = propertyValue.cast_out(datatype)
  File "... lib/python3.8/site-packages/bacpypes/constructeddata.py", line 1346, in cast_out
    helper = klass(self.tagList[0])
  File "... lib/python3.8/site-packages/bacpypes/primitivedata.py", line 1128, in __init__
    self.decode(arg)
  File "... lib/python3.8/site-packages/bacpypes/primitivedata.py", line 1209, in decode
    raise InvalidTag("enumerated application tag required")
@coveralls
Copy link

coveralls commented Dec 17, 2020

Coverage Status

Coverage increased (+0.001%) to 46.267% when pulling 3b5eba0 on gnmerritt:johnson-controls-nce into 834cbd5 on ChristianTremblay:develop.

@ChristianTremblay
Copy link
Owner

Those seems like good catches. In what context does the application null property occurs ? Never saw that....

Regarding the formatting of debug, I was not aware of that... and was slowly converting eveythin to ".format" style until I decide to go for f-string. Do you know if the issue will be the same with f-string ?

@gnmerritt
Copy link
Contributor Author

Yeah, so .format or f"{}" are both evaluated as part of the function call (and always happen even if the line isn't printed) - the syntax I switched to uses logging's built-in string formatting and so it's smart enough to skip the formatting if the logger isn't going to print. In my own apps I tend to split the difference by using f-strings for info/warn/error and trying to remember to use the special syntax for debug statements. I think it probably doesn't matter unless the things you're printing are properties that cause lots of network/disk IO.

For the application null thing: I saw it when trying to read Points.bacnet_properties for one of the points on the NCE. No idea how common the case is in the wild but I checked the packets out in tcpdump and the null case appears to be a well-formed bacnet message, so I figured this was the best way to handle it. The property had a datatype of bacpypes.basetypes.BinaryPV and here was the debug info I pulled:

pv=<bacpypes.constructeddata.Any object at 0x7fcaebc52760>, datatype=<class 'bacpypes.basetypes.BinaryPV'>
<bacpypes.primitivedata.Tag(null) instance at 0x7fcaebcbea00>, data=bytearray(b'')
                <bacpypes.primitivedata.Tag(null) instance at 0x7fcaebcbea00>
                    tagClass = 0 application
                    tagNumber = 0 null
                    tagLVT = 0
                    tagData = ''
 tagClass=0, appTagClass=0
 tagNum=0, enumAppTag=9

@ChristianTremblay ChristianTremblay merged commit 2eafd10 into ChristianTremblay:develop Dec 17, 2020
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

Successfully merging this pull request may close these issues.

3 participants