src/occ_405/cmdh/cmdh_snapshot.c
// Function Specification
//
// Name: cmdh_snapshot_sync
//
// Description: Resets the snapshot buffer array and starts a new snapshot buffer from time 0.
//
// End Function Specification
Function Specification
Name: cmdh_snapshot_sync

Resets the snapshot buffer array and starts a new snapshot buffer from time 0.

End Function Specification
Function Specification Name : cmdh_snapshot_sync Resets the snapshot buffer array and starts a new snapshot buffer from time 0 . End Function Specification
errlHndl_t cmdh_snapshot_sync(const cmdh_fsp_cmd_t * i_cmd_ptr,
                                    cmdh_fsp_rsp_t * o_rsp_ptr)
{
    cmdh_snapshot_sync_query_t      *l_cmd_ptr = (cmdh_snapshot_sync_query_t *) i_cmd_ptr;
    cmdh_snapshot_sync_resp_t       *l_resp_ptr = (cmdh_snapshot_sync_resp_t *) o_rsp_ptr;
    errlHndl_t                      l_err = NULL;
    uint8_t                         l_query_sz = 0;
    ERRL_RC                         l_rc = 0;
    do
    {
        l_query_sz = CMDH_DATALEN_FIELD_UINT16(i_cmd_ptr);
        if(l_query_sz != CMDH_SNAPSHOT_SYNC_DATA_SIZE)
        {
            TRAC_ERR("cmdh_snapshot_sync: Received an invalid packet size. Expecting 1 byte, received:%i",
                     l_query_sz);
            l_rc = ERRL_RC_INVALID_CMD_LEN;
            break;
        }
        l_cmd_ptr = (cmdh_snapshot_sync_query_t *)i_cmd_ptr;
        if (CMDH_SNAPSHOT_SYNC_VERSION != l_cmd_ptr->version)
        {
            TRAC_ERR("cmdh_snapshot_sync: Version %i cmd is not supported.", l_cmd_ptr->version);
            l_rc = ERRL_RC_INVALID_DATA;
            break;
        }
        g_cmdh_snapshot_reset = TRUE;
        g_cmdh_snapshot_cur_index = CMDH_SNAPSHOT_DEFAULT_CUR_INDEX;
        l_rc = ssx_timer_schedule(&G_snapshotTimer, 0, SSX_SECONDS(30));
        if (l_rc != SSX_OK)
        {
            TRAC_ERR("cmdh_snapshot_sync: reseting the snapshot timer failed.");
            break;
        }
        l_resp_ptr->data_length[0] = 0;
        l_resp_ptr->data_length[1] = 0;
        G_rsp_status = 0;
    }while(FALSE);
    if (l_rc)
    {
        cmdh_build_errl_rsp(i_cmd_ptr, o_rsp_ptr, l_rc, &l_err);
    }
    return(l_err);
}
errlHndl_t cmdh_snapshot_sync ( const cmdh_fsp_cmd_t * i_cmd_ptr , cmdh_fsp_rsp_t * o_rsp_ptr ) { cmdh_snapshot_sync_query_t * l_cmd_ptr = ( cmdh_snapshot_sync_query_t * ) i_cmd_ptr ; cmdh_snapshot_sync_resp_t * l_resp_ptr = ( cmdh_snapshot_sync_resp_t * ) o_rsp_ptr ; errlHndl_t l_err = NULL ; uint8_t l_query_sz = 0 ; ERRL_RC l_rc = 0 ; do { l_query_sz = CMDH_DATALEN_FIELD_UINT16 ( i_cmd_ptr ) ; if ( l_query_sz != CMDH_SNAPSHOT_SYNC_DATA_SIZE ) { TRAC_ERR ( " " , l_query_sz ) ; l_rc = ERRL_RC_INVALID_CMD_LEN ; break ; } l_cmd_ptr = ( cmdh_snapshot_sync_query_t * ) i_cmd_ptr ; if ( CMDH_SNAPSHOT_SYNC_VERSION != l_cmd_ptr -> version ) { TRAC_ERR ( " " , l_cmd_ptr -> version ) ; l_rc = ERRL_RC_INVALID_DATA ; break ; } g_cmdh_snapshot_reset = TRUE ; g_cmdh_snapshot_cur_index = CMDH_SNAPSHOT_DEFAULT_CUR_INDEX ; l_rc = ssx_timer_schedule ( & G_snapshotTimer , 0 , SSX_SECONDS ( 30 ) ) ; if ( l_rc != SSX_OK ) { TRAC_ERR ( " " ) ; break ; } l_resp_ptr -> data_length [ 0 ] = 0 ; l_resp_ptr -> data_length [ 1 ] = 0 ; G_rsp_status = 0 ; } while ( FALSE ) ; if ( l_rc ) { cmdh_build_errl_rsp ( i_cmd_ptr , o_rsp_ptr , l_rc , & l_err ) ; } return ( l_err ) ; }
Function Specification
Name: cmdh_snapshot_sync
Function Specification Name : cmdh_snapshot_sync
// Verify query data size // Check received packet version // Set the global reset flag, that will cause all saved data to be cleared in the // next callback that is done every 30 seconds via a timer. // Reset current index to stop any possible calls from tmgt to get snapshot buffers. // Reset timer and start counting from now. This will cause a call to the snapshot_callback // function below which will reset the other globals based on the fact that g_cmdh_snapshot_reset // is set to true. // Build Error Response packet