Coder Social home page Coder Social logo

Comments (2)

JoelBender avatar JoelBender commented on August 16, 2024

It looks like you are writing the entire priority array in one shot when you should be writing a Null to the to the Present_Value property and providing the priority as a the parameter to the Write Property Request. The Priority_Array is a read-only property.

>>> request = WritePropertyRequest(destination=Address("1.2.3.4"),
...     objectIdentifier=('analogValue', 1), propertyIdentifier='presentValue',
...     propertyValue=Any(),
...     priority=8
... )
>>> request.propertyValue.cast_in(Null())

You really don't want to stomp on the priority array items that have been written by other, perhaps higher priority processes, and you don't want to have to read the whole thing then write it back out again for the same reason, so it's read-only.

from bacpypes.

kheldaroz-droid avatar kheldaroz-droid commented on August 16, 2024

thanks Joel - that actually makes sense - maybe I'm getting the hang of python / BACnet

updated code for reference

`def release_bacnet_priority(device_instance, addr, object_type, priority=8):
logging.info(f"Releasing Priority {priority} on Device {device_instance} at {addr} ({object_type})")

# Create the write request
request = WritePropertyRequest(
    objectIdentifier=(object_type, device_instance),
    propertyIdentifier='presentValue',
    propertyValue=Any(),
    priority=priority

)
request.propertyValue.cast_in(Null())
request.pduDestination = Address(addr)
iocb = IOCB(request)

# Attach the address to the IOCB instance
iocb.addr = addr
iocb.object_type = object_type

callback_function = lambda iocb, prop='presentValue': on_property_release_response(iocb, prop)
iocb.add_callback(callback_function)
this_application.request_io(iocb)

def on_property_release_response(iocb, prop):
if iocb.ioError:
logging.error(f"{color.RED}Error Releasing to property {prop} on {iocb.addr} ({iocb.object_type}): {iocb.ioError}{color.END}")
else:
logging.info(f"{color.GREEN}Successfully Released Priority on property {prop} on {iocb.addr} ({iocb.object_type}){color.END}")`

from bacpypes.

Related Issues (20)

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.