Example #1
0
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
Example #2
0
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
Example #3
0
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
Example #4
0
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
Example #5
0
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()
Example #6
0
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()