Giter Club home page Giter Club logo

bacpypes's Introduction

BACpypes

BACpypes provides a BACnet application layer and network layer written in Python for daemons, scripting, and graphical interfaces. This is the current project, not the one over on SourceForge.

Join the chat at https://gitter.im/JoelBender/bacpypes

Documentation Status

bacpypes's People

Contributors

cambrian-dk avatar christiantremblay avatar db-cl avatar dependabot[bot] avatar gitter-badger avatar hax404 avatar jci-cfoxr avatar joelbender avatar kjlockhart avatar kunalsaini avatar nilstoedtmann avatar richardlitt avatar sjlongland avatar zoopp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bacpypes's Issues

Samples use old ServicesSupported

While working on porting the sample applications I noticed that they all use the old "single bit at a time" way of setting the values in the ServicesSupported bit list. It seems like they should be updated to use the simpler syntax:

protocolServicesSupported = ServicesSupported(['whoIs','iAm','readProperty','writeProperty']).value

Is it better? Comments welcome.

Enumeration encoding broken

When a primitive data Enumeration is initialized with an integer, it fails to encode into a tag, because an if should be an elif. Fix the bug and fix the tests.

PyPI contains invalid wheel

Version 0.13.0 that was released and is on PyPI contains bacpypes-0.13.0-py2.py3-none-any.whl which is incorrect, there should be separate wheels for the different versions of Python.

Support 135-2012aw

Extend the CHANGE_OF_STATE Event Algorithm for All Discrete Types
Add a New Event Algorithm CHANGE_OF_DISCRETE_VALUE
Add a New Fault Algorithm FAULT_OUT_OF_RANGE
Extend the Loop Object Type to Support Specific Low and High Error Limits
Add the Ability to Report Faults to Date and Time Related Value Objects
Add the Ability to Report Faults to the Command, Device, and Notification Class Objects

http://www.bacnet.org/Addenda/Add-135-2012-an-at-au-av-aw-ax-az-Final.pdf

Overly aggressive use of "".format()

There are lots of places where "".format() is used but is incompatible with py25. Replace these with the "" % () formatting syntax in the py25 source.

Decoding empty tag should raise DecodingError

There are tests in almost all of the primitive data test modules that attempts to decode from an empty tag, similar to this one for enumerations:

    with self.assertRaises(DecodingError):
        obj = Enumerated(enumerated_tag(''))

The issue is to make this work correctly, that is, raise the exception, for all of the datatypes where it is appropriate.

Support 135-2012bg

Add engineering units
Harmonize Confirmed and Unconfirmed EventNotification message text handling
Ensure Alert Enrollment objects do not send notifications which require acknowledgment
Allow selection of the Nth last day of the month in a BACnetWeekNDay
Remove initiation of GetEnrollmentSummary from AE-AS-A
Ensure UTC_Offset is configurable
Clarify ReadRange
Clarify the effect of changing Buffer_Size
Stop MS/TP nodes from sending POLL_FOR_MASTER frames to themselves
Improve the Clause 12 pre-amble
Fix the Notification_Class property of the Notification Class object

http://www.bacnet.org/Addenda/Add-135-2012bg-PPR1-Draft-3_chair_approved.pdf

MSTP MAC address are received as string

mstp mac address are received as string like : b'\x04' instead of a simple conversion

example :

> whois 3:4
> pduSource = <RemoteStation 3:b'\x04'>
iAmDeviceIdentifier = ('device', 5004)
maxAPDULengthAccepted = 480
segmentationSupported = segmentedBoth
vendorID = 5

ObjectIdentifier copy ctor failing

In ObjectIdentifier.__init__() the version that does a value copy from one ObjectIdentifier to another is wrong, the check for isinstance is in the wrong place. Trivial fix.

Objects / Write property allows wrong datatype by presumption

objects.py
From line 144 to 220

    def WriteProperty(self, obj, value, arrayIndex=None, priority=None, direct=False):
        if _debug:
            Property._debug("WriteProperty(%s) %s %r arrayIndex=%r priority=%r direct=%r",
                self.identifier, obj, value, arrayIndex, priority, direct
                )

        if (not direct):
            # see if it must be provided
            if not self.optional and value is None:
                raise ValueError("%s value required" % (self.identifier,))

            # see if it can be changed
            if not self.mutable:
                raise ExecutionError(errorClass='property', errorCode='writeAccessDenied')

    #=================================
    # THIS IS THE PART I'M QUESTIONNING
        #if it's atomic assume correct datatype
        if issubclass(self.datatype, Atomic):
            if _debug: Property._debug("    - property is atomic, assumed correct type")
        if isinstance(value, self.datatype):
            if _debug: Property._debug("    - correct type")
        elif arrayIndex is not None:
            if not issubclass(self.datatype, Array):
                raise ExecutionError(errorClass='property', errorCode='propertyIsNotAnArray')

            # check the array
            arry = obj._values[self.identifier]
            if arry is None:
                raise RuntimeError("%s uninitialized array" % (self.identifier,))

            # seems to be OK, let the array object take over
            if _debug: Property._debug("    - forwarding to array")
            arry[arrayIndex] = value

            return
        elif value is not None:
            # coerce the value
            value = self.datatype(value)
            if _debug: Property._debug("    - coerced the value: %r", value)

        # seems to be OK
        obj._values[self.identifier] = value

It allows value of any kind to be sent to a write request
example : I can send a string to writeProperty of a BinaryValue...

Actually test that should fail are passing

I think we should restraint the value sent to a writeProperty fucntion to the datatype selected in the obejct.

Comparing the dataype of the object class.... without regard to the value sent to the function should be remove I think.

Test issue for HuBoard

This is a test issue to see how HuBoard changes an issue when mucking around with its UI. There is no related branch.

Extending enumerations

I thought that I had put in code that walked the class inheritance tree when it built the translation table for enumerations. The idea begin that for some enumerations that can be extended with proprietary values (like ObjectType) that the developer could just add the additional name/value pairs to the enumerations dictionary and it would pick up the rest. Resurrect this feature, and add appropriate tests.

Time init string parsing is broken

Some time ago I added a feature to parse string versions of time values like this:

value = Time("01:02:03.04")

But apparently an old bug reared its ugly head. It's broken, but a trivial fix.

Console logging attempting to sort dict_keys

In the consolelogging.py module the code is attempting to sort the result of calling logging.Logger.manager.loggerDict.keys() which returns a dict_keys object in py34. Change this to using the sorted() function that works in py25, py27 and py34.

CharacterString Encoding

ERROR:bacpypes.comm.ApplicationServiceElement:exception: TypeError("Can't convert 'bytes' object to str implicitly",)
Traceback (most recent call last):
File "C:\Users\ctremblay.SERVISYS\AppData\Local\Continuum\Anaconda3\lib\site-packages\bacpypes-0.13.1-py3.4.egg\bacpypes\app.py", line 231, in indication
helperFn(apdu)
File "C:\Users\ctremblay.SERVISYS\AppData\Local\Continuum\Anaconda3\lib\site-packages\bacpypes-0.13.1-py3.4.egg\bacpypes\app.py", line 327, in do_ReadPropertyRequest
resp.propertyValue.cast_in(value)
File "C:\Users\ctremblay.SERVISYS\AppData\Local\Continuum\Anaconda3\lib\site-packages\bacpypes-0.13.1-py3.4.egg\bacpypes\constructeddata.py", line 1013, in cast_in
element.encode(tag)
File "C:\Users\ctremblay.SERVISYS\AppData\Local\Continuum\Anaconda3\lib\site-packages\bacpypes-0.13.1-py3.4.egg\bacpypes\primitivedata.py", line 817, in encode
tag.set_app_data(Tag.characterStringAppTag, (chr(self.strEncoding)+self.strValue.encode('latin-1')))
TypeError: Can't convert 'bytes' object to str implicitly

WARNING:bacpypes.bvllservice.UDPMultiplexer:unsupported message

Message are correctly sent to the network (verified with Wireshark)
Response is misinterpreted somewhere and give the warning...

Debug :

WARNING:bacpypes.bvllservice.UDPMultiplexer:unsupported message
    pduSource = <Address 2:b'\x05'>
    pduExpectingReply = 0
    pduNetworkPriority = 0
    apduType = 7
    apduSrv = False
    apduInvokeID = 1
    apduAbortRejectReason = 65
    pduData = x''

Invalid reference to register_object_types

In LocalDeviceObject.init() there is new code that checks to make sure that the class is registered correctly with its vendor identifier. When the code was changed to clean up imports, the object module is no longer completely imported, but the reference to object.register_object_type() and object.register_object_types is no longer correct.

Opening/Closing Tag Encoding/Decoding

For OpeningTag and ClosingTag tags the encoding and decoding is wrong when the tag number is greater than 14. For example, the encoding of OpeningTag(15) should be 'FE0F'. There aren't any applications for tag numbers this large in the current standard, but it's still wrong!

Date init string parsing is broken

Similar to the Time bug #47 the Date also has a bug, this fails:

value = Date("1/2/3")

This should be 02-JAN-2003 and correctly calculate the day-of-week. Trivial fix.

Suspending tasks with no task manager

In the task module, it is acceptable to install a task with no task manager created, the code just adds the task to the list of uninstalled tasks and they will be installed when the task manager is created. However, when a task is installed and then suspended, the call to suspend_task() fails.

Fix the code to remove the task from the uninstalled tasks if there is no task manager to delegate the activity.

Echo is broken

The Echo class in the comm module is broken, the clientPeer and serverPeer checks are backwards, just remove them.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.