AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/ports/linux/dlmstp_linux.c
uint16_t MSTP_Put_Receive(
    volatile struct mstp_port_struct_t *mstp_port)
{
    uint16_t pdu_len = 0;
    SHARED_MSTP_DATA *poSharedData = (SHARED_MSTP_DATA *) mstp_port->UserData;

    if (!poSharedData) {
        return 0;
    }

    if (!poSharedData->Receive_Packet.ready) {
        /* bounds check - maybe this should send an abort? */
        pdu_len = mstp_port->DataLength;
        if (pdu_len > sizeof(poSharedData->Receive_Packet.pdu))
            pdu_len = sizeof(poSharedData->Receive_Packet.pdu);
        memmove((void *) &poSharedData->Receive_Packet.pdu[0],
            (void *) &mstp_port->InputBuffer[0], pdu_len);
        dlmstp_fill_bacnet_address(&poSharedData->Receive_Packet.address,
            mstp_port->SourceAddress);
        poSharedData->Receive_Packet.pdu_len = mstp_port->DataLength;
        poSharedData->Receive_Packet.ready = true;
        pthread_cond_signal(&poSharedData->Receive_Packet_Flag);
    }

    return pdu_len;
}
/* for the MS/TP state machine to use for putting received data */
for the MS/TP state machine to use for putting received data
for the MS / TP state machine to use for putting received data
uint16_t MSTP_Put_Receive(
    volatile struct mstp_port_struct_t *mstp_port)
{
    uint16_t pdu_len = 0;
    SHARED_MSTP_DATA *poSharedData = (SHARED_MSTP_DATA *) mstp_port->UserData;
    if (!poSharedData) {
        return 0;
    }
    if (!poSharedData->Receive_Packet.ready) {
        pdu_len = mstp_port->DataLength;
        if (pdu_len > sizeof(poSharedData->Receive_Packet.pdu))
            pdu_len = sizeof(poSharedData->Receive_Packet.pdu);
        memmove((void *) &poSharedData->Receive_Packet.pdu[0],
            (void *) &mstp_port->InputBuffer[0], pdu_len);
        dlmstp_fill_bacnet_address(&poSharedData->Receive_Packet.address,
            mstp_port->SourceAddress);
        poSharedData->Receive_Packet.pdu_len = mstp_port->DataLength;
        poSharedData->Receive_Packet.ready = true;
        pthread_cond_signal(&poSharedData->Receive_Packet_Flag);
    }
    return pdu_len;
}
uint16_t MSTP_Put_Receive ( volatile struct mstp_port_struct_t * mstp_port ) { uint16_t pdu_len = 0 ; SHARED_MSTP_DATA * poSharedData = ( SHARED_MSTP_DATA * ) mstp_port -> UserData ; if ( ! poSharedData ) { return 0 ; } if ( ! poSharedData -> Receive_Packet . ready ) { pdu_len = mstp_port -> DataLength ; if ( pdu_len > sizeof ( poSharedData -> Receive_Packet . pdu ) ) pdu_len = sizeof ( poSharedData -> Receive_Packet . pdu ) ; memmove ( ( void * ) & poSharedData -> Receive_Packet . pdu [ 0 ] , ( void * ) & mstp_port -> InputBuffer [ 0 ] , pdu_len ) ; dlmstp_fill_bacnet_address ( & poSharedData -> Receive_Packet . address , mstp_port -> SourceAddress ) ; poSharedData -> Receive_Packet . pdu_len = mstp_port -> DataLength ; poSharedData -> Receive_Packet . ready = true ; pthread_cond_signal ( & poSharedData -> Receive_Packet_Flag ) ; } return pdu_len ; }
for the MS/TP state machine to use for putting received data
for the MS / TP state machine to use for putting received data
/* bounds check - maybe this should send an abort? */