def recv_response(request_id, timeout=3.0): r = network.recv_response(request_id, timeout) if r.pdu_type == BACNET_ERROR_PDU: raise BACnetError(r) elif r.pdu_type == BACNET_REJECT_PDU: raise BACnetReject(r) elif r.pdu_type == BACNET_ABORT_PDU: raise BACnetAbort(r) return r
def recv_response(request_id): r = network.recv_response(request_id, 10.0) if r.pdu_type == BACNET_ERROR_PDU: failure = 'error' elif r.pdu_type == BACNET_REJECT_PDU: failure = 'reject' elif r.pdu_type == BACNET_ABORT_PDU: failure = 'abort' else: failure = None if failure: raise 'BACnet error', (r, failure) if not r: raise 'BACnet error', (r, 'timeout') return r
def recv_response(request_id): r = network.recv_response(request_id, 10.0) if r.pdu_type == BACNET_ERROR_PDU: failure = "error" elif r.pdu_type == BACNET_REJECT_PDU: failure = "reject" elif r.pdu_type == BACNET_ABORT_PDU: failure = "abort" else: failure = None if failure: raise "BACnet error", (r, failure) if not r: raise "BACnet error", (r, "timeout") return r
def read_property(device, prop): global threadlock1 results = [] threadlock1.acquire() try: object = prop[0] instance = prop[1] property = prop[2] arrayidx = None if len(prop) > 3: arrayidx = prop[3] rp = npdu.NPDU() rp.pdu_type = BACNET_CONFIRMED_SERVICE_REQUEST_PDU rp.choice = 12 if arrayidx: raise "Not supported" else: rp.data = rp.data + pack(">BIBB", 0x0C, object << 22 | instance, 0x19, property) request_id = network.send_request(device, rp) r = network.recv_response(request_id) return r finally: threadlock1.release()
def read_property(device, prop): global threadlock1 results = [] threadlock1.acquire() try: object = prop[0] instance = prop[1] property = prop[2] arrayidx = None if len(prop) > 3: arrayidx = prop[3] rp = npdu.NPDU() rp.pdu_type = BACNET_CONFIRMED_SERVICE_REQUEST_PDU rp.choice = 12 if arrayidx: raise 'Not supported' else: rp.data = rp.data + pack('>BIBB', 0x0c, object << 22 | instance, 0x19, property) request_id = network.send_request(device, rp) r = network.recv_response(request_id) return r finally: threadlock1.release()