Comments (6)
Just to be sure I understand it right. Is this code would need to raise the error ?
from bacpypes.primitivedata import Tag, Enumerated
from bacpypes.debugging import bacpypes_debugging, ModuleLogger, xtob
tag = Tag(Tag.applicationTagClass, Tag.enumeratedAppTag, 1, xtob(''))
obj = Enumerated(tag)
# ! Bang -> Decoding Error
Is a specific call to decode() necessary ?
from bacpypes.
That's one form that will generate an error. Your example shows a tag that is inconsistent because the LVT field (in this case interpreted as "length") is one (1) but the length of the tag data is zero (0). The current code doesn't have test for this error, so adding something like this is a good idea:
if (tag.tagLVT != len(tag.tagData)):
raise DecodingError("inconsistent tag")
The sample test is equivalent to this, which should also raise an error:
tag = Tag(Tag.applicationTagClass, Tag.enumeratedAppTag, 0, xtob(''))
because there must be at least one octet of data (and four octets for Real, Date, and Time, etc.) The test code is already in tests/test_primitive_data/test_enumerated.py
, it's just commented out:
# with self.assertRaises(DecodingError):
# obj = Enumerated(enumerated_tag(''))
Your mission, now that this is assigned to you :-), is to uncomment the test and fix the decode()
function.
It's not necessary to explicitly call decode()
because having it implicitly called by __init__()
is part of the "signature" of the function.
from bacpypes.
You are going to be making (or you have already made) a new branch issue-50
from stage
, correct? If I'm thinking correctly, it should contain the 49f990c commit and go forward from there.
from bacpypes.
After reviewing 18.9 Reject Reason in the standard, perhaps the exception should be called InvalidTag
:
INVALID_TAG - While parsing a message, an invalid tag was encountered. Since an invalid tag could confuse the parsing logic, any of the following Reject Reasons may also be generated in response to a confirmed request containing an invalid tag: INCONSISTENT_PARAMETERS, INVALID_PARAMETER_DATA_TYPE, MISSING_REQUIRED_PARAMETER, and TOO_MANY_ARGUMENTS.
When this exception is raised during the decoding of an APDU before it is sent upstream for processing, it will need to be trapped and a RejectPDU
sent to the client (I'll make a separate issue).
from bacpypes.
Create an InvalidTagError
exception that inherit from DecodingError (to be confirmed... if ok, if not, just change it to inherit from ValueError
This line is added to primitivedata encode function :
if tag.tagData == b'':
raise InvalidTagError('empty tag')
Did it for :
- Enumerated
- Date
- Double
- Integer
- object_identifier
- object_type
- real
- time
- unsigned
Seems not appropriate for :
- Null
- Boolean
- BitString
- octet_string
from bacpypes.
This has been subsumed by #58, which has all the reject and abort exceptions, includes all three distributions, and I included the updates to the tests as well. I'm closing this issue and abandoning the branch.
from bacpypes.
Related Issues (20)
- Max APDU not segmenting correct HOT 1
- Potential Error in _parse_wp_args HOT 1
- inconsistent COV subscription response: noReponse vs timeout
- [Question] Proper BBMD.py usage HOT 3
- BACnet Services request notification
- asyncore removed from python 3.12 HOT 4
- Issue in dockerising an MSTP application using Misty and BACpypes HOT 1
- Problem with ConfirmedEventNotification in BACpypes Sample HOT 2
- BACnet device is not discoverable in Yabe HOT 4
- MAC Address from I-Am HOT 2
- Do we need to modify our code if we are prefering BACnet port as TCP over UDP? HOT 1
- Clearing / Releasing a priority HOT 2
- Dependency asyncore has been removed in python 3.12. HOT 2
- How do I alter the object properties' values while the simulator is running? HOT 1
- Remote network responds to WhoIsIAm but not ReadProperty HOT 5
- COV - how is Priority handled HOT 1
- COV subscription setting lifetime to 0 causes Error HOT 2
- Erroneous Day-of-week code in packet when building readRange log-buffer request with time-range HOT 6
- Upload GitHub release and PyPI archive HOT 2
- Python 3.12 Unsupported version of Python HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bacpypes.