src/occ_405/cmdh/cmdh_snapshot.c
// Function Specification
//
// Name: cmdh_snapshot_buffer_nonite
//
// Description: Returns the requested snapshot buffer to tmgt.
//
// End Function Specification
Function Specification
Name: cmdh_snapshot_buffer_nonite

Returns the requested snapshot buffer to tmgt.

End Function Specification
Function Specification Name : cmdh_snapshot_buffer_nonite Returns the requested snapshot buffer to tmgt . End Function Specification
ERRL_RC cmdh_snapshot_buffer_nonite(const cmdh_fsp_cmd_t *i_cmd_ptr,
                                          cmdh_fsp_rsp_t *o_rsp_ptr)
{
    cmdh_get_snapshot_query_t   *l_cmd_ptr      = (cmdh_get_snapshot_query_t *) i_cmd_ptr;
    ERRL_RC                     l_rc            = ERRL_RC_SUCCESS;
    cmdh_get_snapshot_resp_v0_t *l_rsp_ptr      = (cmdh_get_snapshot_resp_v0_t*) o_rsp_ptr;
    uint8_t                     l_newest        = 0;
    uint8_t                     l_oldest        = 0;
    uint8_t                     l_req_idx       = 0;
    uint8_t                     i               = 0;
    do
    {
        if (g_cmdh_snapshot_cur_index == CMDH_SNAPSHOT_DEFAULT_CUR_INDEX)
        {
            break;
        }
        cmdh_snapshot_find_oldest_newest(&l_oldest, &l_newest);
        l_rsp_ptr->oldest_id = g_cmdh_snapshot_array[l_oldest].current_id;
        l_rsp_ptr->newest_id = g_cmdh_snapshot_array[l_newest].current_id;
        if (l_cmd_ptr->getnewest)
        {
            l_req_idx = l_newest;
        }
        else
        {
            for (i =0; i< CMDH_SNAPSHOT_MAX; i++)
            {
                if (g_cmdh_snapshot_array[i].current_id == l_cmd_ptr->requested_id)
                {
                    l_req_idx = i;
                    break;
                }
            }
            if (i == CMDH_SNAPSHOT_MAX)
            {
                l_req_idx = l_newest;
            }
        }
        memcpy(&(l_rsp_ptr->snapshot),
               &(g_cmdh_snapshot_array[l_req_idx]),
               sizeof(cmdh_snapshot_buffer_t));
        uint16_t l_size = 2 + sizeof(cmdh_snapshot_buffer_t); 
        o_rsp_ptr->data_length[0] = ((uint8_t *)&l_size)[0];
        o_rsp_ptr->data_length[1] = ((uint8_t *)&l_size)[1];
    } while (0);
    return(l_rc);
}
ERRL_RC cmdh_snapshot_buffer_nonite ( const cmdh_fsp_cmd_t * i_cmd_ptr , cmdh_fsp_rsp_t * o_rsp_ptr ) { cmdh_get_snapshot_query_t * l_cmd_ptr = ( cmdh_get_snapshot_query_t * ) i_cmd_ptr ; ERRL_RC l_rc = ERRL_RC_SUCCESS ; cmdh_get_snapshot_resp_v0_t * l_rsp_ptr = ( cmdh_get_snapshot_resp_v0_t * ) o_rsp_ptr ; uint8_t l_newest = 0 ; uint8_t l_oldest = 0 ; uint8_t l_req_idx = 0 ; uint8_t i = 0 ; do { if ( g_cmdh_snapshot_cur_index == CMDH_SNAPSHOT_DEFAULT_CUR_INDEX ) { break ; } cmdh_snapshot_find_oldest_newest ( & l_oldest , & l_newest ) ; l_rsp_ptr -> oldest_id = g_cmdh_snapshot_array [ l_oldest ] . current_id ; l_rsp_ptr -> newest_id = g_cmdh_snapshot_array [ l_newest ] . current_id ; if ( l_cmd_ptr -> getnewest ) { l_req_idx = l_newest ; } else { for ( i = 0 ; i < CMDH_SNAPSHOT_MAX ; i ++ ) { if ( g_cmdh_snapshot_array [ i ] . current_id == l_cmd_ptr -> requested_id ) { l_req_idx = i ; break ; } } if ( i == CMDH_SNAPSHOT_MAX ) { l_req_idx = l_newest ; } } memcpy ( & ( l_rsp_ptr -> snapshot ) , & ( g_cmdh_snapshot_array [ l_req_idx ] ) , sizeof ( cmdh_snapshot_buffer_t ) ) ; uint16_t l_size = 2 + sizeof ( cmdh_snapshot_buffer_t ) ; o_rsp_ptr -> data_length [ 0 ] = ( ( uint8_t * ) & l_size ) [ 0 ] ; o_rsp_ptr -> data_length [ 1 ] = ( ( uint8_t * ) & l_size ) [ 1 ] ; } while ( 0 ) ; return ( l_rc ) ; }
Function Specification
Name: cmdh_snapshot_buffer_nonite
Function Specification Name : cmdh_snapshot_buffer_nonite
// Check case where there are no snapshot buffers available. // Determine newest and oldest buffer. // Determine which snapshot buffer is requested by TMGT // Find requested snapshot, or if not available grab latest. // Copy the requested snapshot buffer into the response buffer. // Calculate returned data size. // 2 bytes for newest and oldest + size of snapshots.