Robus/src/reception.c
void Recep_GetHeader(volatile uint8_t *data)
{
    // Catch a byte.
    MsgAlloc_SetData(*data);
    data_count++;

    // Check if we have all we need.
    switch (data_count)
    {
        case 1: //reset CRC computation
            ctx.tx.lock = true;
            // Switch the transmit status to disable to be sure to not interpreat the end timeout as an end of transmission.
            ctx.tx.status = TX_DISABLE;
            crc_val       = 0xFFFF;
            break;

        case 3: //check if message is for the node
            if (Recep_NodeConcerned((header_t *)&current_msg->header) == false)
            {
                MsgAlloc_ValidHeader(false, data_size);
                ctx.rx.callback = Recep_Drop;
                return;
            }
            break;

        case (sizeof(header_t)): //Process at the header
#ifdef DEBUG
            printf("*******header data*******\n");
            printf("protocol : 0x%04x\n", current_msg->header.protocol);       /*!< Protocol version. */
            printf("target : 0x%04x\n", current_msg->header.target);           /*!< Target address, it can be (ID, Multicast/Broadcast, Type). */
            printf("target_mode : 0x%04x\n", current_msg->header.target_mode); /*!< Select targeting mode (ID, ID+ACK, Multicast/Broadcast, Type). */
            printf("source : 0x%04x\n", current_msg->header.source);           /*!< Source address, it can be (ID, Multicast/Broadcast, Type). */
            printf("cmd : 0x%04x\n", current_msg->header.cmd);                 /*!< msg definition. */
            printf("size : 0x%04x\n", current_msg->header.size);               /*!< Size of the data field. */
#endif
            // Reset the catcher.
            data_count = 0;

            // Switch state machine to data reception
            ctx.rx.callback = Recep_GetData;
            // Cap size for big messages
            if (current_msg->header.size > MAX_DATA_MSG_SIZE)
            {
                data_size = MAX_DATA_MSG_SIZE;
            }
            else
            {
                data_size = current_msg->header.size;
            }

            if ((ctx.rx.status.rx_framing_error == false))
            {
                if (data_size)
                {
                    MsgAlloc_ValidHeader(true, data_size);
                }
            }
            else
            {
                MsgAlloc_ValidHeader(false, data_size);
                ctx.rx.callback = Recep_Drop;
                return;
            }
            break;

        default:
            break;
    }
    LuosHAL_ComputeCRC((uint8_t *)data, (uint8_t *)&crc_val);
}
/******************************************************************************
 * @brief Callback to get a complete header
 * @param data come from RX
 * @return None
 ******************************************************************************/
@brief Callback to get a complete header
@param data come from RX
@return None
@brief Callback to get a complete header @param data come from RX @return None
void Recep_GetHeader(volatile uint8_t *data)
{
    MsgAlloc_SetData(*data);
    data_count++;
    switch (data_count)
    {
        case 1: 
            ctx.tx.lock = true;
            ctx.tx.status = TX_DISABLE;
            crc_val       = 0xFFFF;
            break;
        case 3: 
            if (Recep_NodeConcerned((header_t *)&current_msg->header) == false)
            {
                MsgAlloc_ValidHeader(false, data_size);
                ctx.rx.callback = Recep_Drop;
                return;
            }
            break;
        case (sizeof(header_t)): 
#ifdef DEBUG
            printf("*******header data*******\n");
            printf("protocol : 0x%04x\n", current_msg->header.protocol);       
            printf("target : 0x%04x\n", current_msg->header.target);           
            printf("target_mode : 0x%04x\n", current_msg->header.target_mode); 
            printf("source : 0x%04x\n", current_msg->header.source);           
            printf("cmd : 0x%04x\n", current_msg->header.cmd);                 
            printf("size : 0x%04x\n", current_msg->header.size);               
#endif
            data_count = 0;
            ctx.rx.callback = Recep_GetData;
            if (current_msg->header.size > MAX_DATA_MSG_SIZE)
            {
                data_size = MAX_DATA_MSG_SIZE;
            }
            else
            {
                data_size = current_msg->header.size;
            }
            if ((ctx.rx.status.rx_framing_error == false))
            {
                if (data_size)
                {
                    MsgAlloc_ValidHeader(true, data_size);
                }
            }
            else
            {
                MsgAlloc_ValidHeader(false, data_size);
                ctx.rx.callback = Recep_Drop;
                return;
            }
            break;
        default:
            break;
    }
    LuosHAL_ComputeCRC((uint8_t *)data, (uint8_t *)&crc_val);
}
void Recep_GetHeader ( volatile uint8_t * data ) { MsgAlloc_SetData ( * data ) ; data_count ++ ; switch ( data_count ) { case 1 : ctx . tx . lock = true ; ctx . tx . status = TX_DISABLE ; crc_val = 0xFFFF ; break ; case 3 : if ( Recep_NodeConcerned ( ( header_t * ) & current_msg -> header ) == false ) { MsgAlloc_ValidHeader ( false , data_size ) ; ctx . rx . callback = Recep_Drop ; return ; } break ; case ( sizeof ( header_t ) ) : #ifdef DEBUG printf ( " \n " ) ; printf ( " \n " , current_msg -> header . protocol ) ; printf ( " \n " , current_msg -> header . target ) ; printf ( " \n " , current_msg -> header . target_mode ) ; printf ( " \n " , current_msg -> header . source ) ; printf ( " \n " , current_msg -> header . cmd ) ; printf ( " \n " , current_msg -> header . size ) ; #endif data_count = 0 ; ctx . rx . callback = Recep_GetData ; if ( current_msg -> header . size > MAX_DATA_MSG_SIZE ) { data_size = MAX_DATA_MSG_SIZE ; } else { data_size = current_msg -> header . size ; } if ( ( ctx . rx . status . rx_framing_error == false ) ) { if ( data_size ) { MsgAlloc_ValidHeader ( true , data_size ) ; } } else { MsgAlloc_ValidHeader ( false , data_size ) ; ctx . rx . callback = Recep_Drop ; return ; } break ; default : break ; } LuosHAL_ComputeCRC ( ( uint8_t * ) data , ( uint8_t * ) & crc_val ) ; }
@brief Callback to get a complete header
 @param data come from RX
 @return None
@brief Callback to get a complete header @param data come from RX @return None
// Catch a byte. // Check if we have all we need. //reset CRC computation // Switch the transmit status to disable to be sure to not interpreat the end timeout as an end of transmission. //check if message is for the node //Process at the header /*!< Protocol version. */ /*!< Target address, it can be (ID, Multicast/Broadcast, Type). */ /*!< Select targeting mode (ID, ID+ACK, Multicast/Broadcast, Type). */ /*!< Source address, it can be (ID, Multicast/Broadcast, Type). */ /*!< msg definition. */ /*!< Size of the data field. */ // Reset the catcher. // Switch state machine to data reception // Cap size for big messages