本文整理汇总了C++中ASSERT_ERR函数的典型用法代码示例。如果您正苦于以下问题:C++ ASSERT_ERR函数的具体用法?C++ ASSERT_ERR怎么用?C++ ASSERT_ERR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ASSERT_ERR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gattc_read_ind_handler
/**
****************************************************************************************
* @brief Handles reception of the @ref GATTC_READ_IND message.
* Generic event received after every simple read command sent to peer server.
* @param[in] msgid Id of the message received (probably unused).
* @param[in] param Pointer to the parameters of the message.
* @param[in] dest_id ID of the receiving task instance (probably unused).
* @param[in] src_id ID of the sending task instance.
* @return If the message was consumed or not.
****************************************************************************************
*/
static int gattc_read_ind_handler(ke_msg_id_t const msgid,
struct gattc_read_ind const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
// Get the address of the environment
struct anpc_env_tag *anpc_env = PRF_CLIENT_GET_ENV(dest_id, anpc);
if (anpc_env != NULL)
{
ASSERT_ERR(anpc_env->operation != NULL);
// Prepare the indication to send to the application
struct anpc_value_ind *ind = KE_MSG_ALLOC(ANPC_VALUE_IND,
anpc_env->con_info.appid,
anpc_env->con_info.prf_id,
anpc_value_ind);
ind->conhdl = gapc_get_conhdl(anpc_env->con_info.conidx);
switch (((struct anpc_cmd *)anpc_env->operation)->operation)
{
// Read Supported New Alert Category Characteristic value
case (ANPC_ENABLE_RD_NEW_ALERT_OP_CODE):
{
ind->att_code = ANPC_RD_SUP_NEW_ALERT_CAT;
ind->value.supp_cat.cat_id_mask_0 = param->value[0];
// If cat_id_mask_1 not present, shall be considered as 0
ind->value.supp_cat.cat_id_mask_1 = (param->length > 1)
? param->value[1] : 0x00;
} break;
case (ANPC_ENABLE_RD_UNREAD_ALERT_OP_CODE):
{
ind->att_code = ANPC_RD_SUP_UNREAD_ALERT_CAT;
ind->value.supp_cat.cat_id_mask_0 = param->value[0];
// If cat_id_mask_1 not present, shall be considered as 0
ind->value.supp_cat.cat_id_mask_1 = (param->length > 1)
? param->value[1] : 0;
} break;
case (ANPC_READ_OP_CODE):
{
ind->att_code = ((struct anpc_read_cmd *)anpc_env->operation)->read_code;
ind->value.ntf_cfg = co_read16(¶m->value[0]);
} break;
default:
{
ASSERT_ERR(0);
} break;
}
// Send the indication
ke_msg_send(ind);
}
// else ignore the message
return (KE_MSG_CONSUMED);
}
示例2: gattc_disc_svc_ind_handler
/**
****************************************************************************************
* @brief Handles reception of the @ref GATTC_DISC_SVC_IND message.
* The handler stores the found service details for service discovery.
* @param[in] msgid Id of the message received (probably unused).
* @param[in] param Pointer to the parameters of the message.
* @param[in] dest_id ID of the receiving task instance (probably unused).
* @param[in] src_id ID of the sending task instance.
* @return If the message was consumed or not.
****************************************************************************************
*/
static int gattc_disc_svc_ind_handler(ke_msg_id_t const msgid,
struct gattc_disc_svc_ind const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
// Get the address of the environment
struct anpc_env_tag *anpc_env = PRF_CLIENT_GET_ENV(dest_id, anpc);
if (anpc_env != NULL)
{
ASSERT_ERR(anpc_env->operation != NULL);
ASSERT_ERR(((struct anpc_cmd *)anpc_env->operation)->operation == ANPC_ENABLE_OP_CODE);
// Keep only one instance of the service
if (anpc_env->nb_svc == 0)
{
// Keep the start handle and the end handle of the service
anpc_env->ans.svc.shdl = param->start_hdl;
anpc_env->ans.svc.ehdl = param->end_hdl;
anpc_env->nb_svc++;
}
}
return (KE_MSG_CONSUMED);
}
示例3: app_module_init_cmp_evt_handler
/**
****************************************************************************************
* @brief Handles reception of the APP_MODULE_INIT_CMP_EVT messgage
* @param[in] msgid Id of the message received.
* @param[in] param Pointer to the parameters of the message.
* @param[in] dest_id ID of the receiving task instance
* @param[in] src_id ID of the sending task instance.
*
* @return If the message was consumed or not.
****************************************************************************************
*/
int app_module_init_cmp_evt_handler(ke_msg_id_t const msgid,
const struct app_module_init_cmp_evt *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
if (ke_state_get(dest_id) == APP_DB_INIT)
{
if (param->status == CO_ERROR_NO_ERROR)
{
// Add next required service in the database
if (app_db_init())
{
// No more service to add in the database, start application
app_db_init_complete_func();
}
}
else
{
// An error has occurred during database creation
ASSERT_ERR(0);
}
}
else
{
// APP_DB_INIT state is used to wait the APP_MODULE_INIT_CMP_EVT message
ASSERT_ERR(0);
}
return (KE_MSG_CONSUMED);
}
示例4: uart_write_ext_wkup_func
void uart_write_ext_wkup_func(uint8_t *bufptr, uint32_t size, void (*callback) (uint8_t))
{
// Sanity check
ASSERT_ERR(bufptr != NULL);
ASSERT_ERR(size != 0);
ASSERT_ERR(uart_env.tx.bufptr == NULL);
GPIO_SetActive (EXT_WAKEUP_PORT, EXT_WAKEUP_PIN);
// Prepare TX parameters
uart_env.tx.size = size;
uart_env.tx.bufptr = bufptr;
uart_env.tx.callback = callback;
/* start data transaction
* first isr execution is done without interrupt generation to reduce
* interrupt load
*/
uart_thr_empty_isr();
if (uart_env.tx.bufptr != NULL)
{
uart_thr_empty_setf(1);
}
GPIO_SetInactive (EXT_WAKEUP_PORT, EXT_WAKEUP_PIN);
}
示例5: ASSERT_ERR
//##ModelId=48DC5D4603A0
bool TiLib_OSD_Driver::Init()
{
// Init a big GraphicsDisplaySurface to draw.
if (gfxMap.uwWidth != 0) {
return false;
}
//enable argb4444 surface to both Component & Composite out
ASSERT_ERR( (GI_NO_ERROR == GraphicsSurfaceCreate( HAL_GRAPHICS_MODE_ARGB8888, SCREEN_WIDTH, SCREEN_HEIGHT, &gfxMap)));
ASSERT_ERR( (GI_NO_ERROR == GraphicsDisplayDestRectSet( HAL_GRAPHICS_DISPLAY0, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)));
ASSERT_ERR( (GI_NO_ERROR == GraphicsDisplayDestRectSet( HAL_GRAPHICS_DISPLAY1, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)));
ASSERT_ERR( (GI_NO_ERROR == GraphicsDisplaySurfaceSet( HAL_GRAPHICS_DISPLAY_ALL, &gfxMap, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)));
GraphicsDisplaySurfaceEnableSet(HAL_GRAPHICS_DISPLAY0, TRUE);
GraphicsDisplaySurfaceEnableSet(HAL_GRAPHICS_DISPLAY1, TRUE);
getSetOnScreenHandle(DO_SET, (PSURFACE) &gfxMap); //set CURRENT_ONSCREEN to newSurf_FrontSurf
//init a pattern in the buffer:
ClearScreen();
return true;
ERR_EXIT:
return false;
}
示例6: gatt_disc_svc_by_uuid_evt_handler
/**
****************************************************************************************
* @brief Handles reception of the @ref GATT_DISC_SVC_BY_UUID_CMP_EVT message.
* @param[in] msgid Id of the message received.
* @param[in] param Pointer to the parameters of the message.
* @param[in] dest_id ID of the receiving task instance.
* @param[in] src_id ID of the sending task instance.
* @return If the message was consumed or not.
****************************************************************************************
*/
static int gatt_disc_svc_by_uuid_evt_handler(ke_msg_id_t const msgid,
struct gatt_disc_svc_by_uuid_cmp_evt const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
// Get the address of the environment
struct cscpc_env_tag *cscpc_env = PRF_CLIENT_GET_ENV(dest_id, cscpc);
// Check if the environment exists
if (cscpc_env != NULL)
{
ASSERT_ERR(cscpc_env->operation != NULL);
ASSERT_ERR(((struct cscpc_cmd *)cscpc_env->operation)->operation == CSCPC_ENABLE_OP_CODE);
// Keep only one instance of the service
if (cscpc_env->nb_svc == 0)
{
// Keep the start handle and the end handle of the service
cscpc_env->cscs.svc.shdl = param->list[0].start_hdl;
cscpc_env->cscs.svc.ehdl = param->list[0].end_hdl;
cscpc_env->nb_svc++;
}
}
// else drop the message
return (KE_MSG_CONSUMED);
}
示例7: LoadFile
bool LoadFile(const char * path, std::vector<byte> * pDataOut, LFK lfk /*= LFK_Binary*/)
{
ASSERT_ERR(path);
ASSERT_ERR(pDataOut);
FILE * pFile = nullptr;
if (fopen_s(&pFile, path, (lfk == LFK_Text) ? "rt" : "rb") != 0)
{
WARN("Couldn't open file %s", path);
return false;
}
ASSERT_ERR(pFile);
// Determine file size
fseek(pFile, 0, SEEK_END);
size_t size = ftell(pFile);
// Read the whole file into memory
pDataOut->resize((lfk == LFK_Text) ? size+1 : size);
rewind(pFile);
size_t sizeRead = fread(&(*pDataOut)[0], sizeof(byte), size, pFile);
// Size can be smaller for text files, due to newline conversion
ASSERT_ERR(sizeRead == size || ((lfk == LFK_Text) && sizeRead <= size));
fclose(pFile);
// Automatically null-terminate text files so string functions can be used
if (lfk == LFK_Text)
{
pDataOut->resize(sizeRead + 1);
(*pDataOut)[sizeRead] = 0;
}
return true;
}
示例8: gapm_cmp_evt_handler
/**
****************************************************************************************
* @brief Handles GAP manager command complete events.
*
* @param[in] msgid Id of the message received.
* @param[in] param Pointer to the parameters of the message.
* @param[in] dest_id ID of the receiving task instance (TASK_GAP).
* @param[in] src_id ID of the sending task instance.
*
* @return If the message was consumed or not.
****************************************************************************************
*/
int gapm_cmp_evt_handler(ke_msg_id_t const msgid,
struct gapm_cmp_evt const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
switch(param->operation) {
// reset completed
case GAPM_RESET:
if(param->status != GAP_ERR_NO_ERROR) {
ASSERT_ERR(0); // unexpected error
}
else {
// set device configuration
struct gapm_set_dev_config_cmd* cmd = KE_MSG_ALLOC(GAPM_SET_DEV_CONFIG_CMD,
TASK_GAPM, TASK_APP, gapm_set_dev_config_cmd);
app_configuration_func(dest_id, cmd);
ke_msg_send(cmd);
}
break;
// device configuration updated
case GAPM_SET_DEV_CONFIG:
if(param->status != GAP_ERR_NO_ERROR) {
ASSERT_ERR(0); // unexpected error
}
else {
app_set_dev_config_complete_func();
}
break;
// Advertising finished
case GAPM_ADV_UNDIRECT:
app_adv_undirect_complete(param->status);
break;
// Directed advertising finished
case GAPM_ADV_DIRECT:
app_adv_direct_complete(param->status);
break;
case GAPM_RESOLV_ADDR:
case GAPM_ADD_DEV_IN_WLIST:
case GAPM_RMV_DEV_FRM_WLIST:
#if (USE_CONNECTION_FSM)
app_con_fsm_handle_cmp_evt(param);
#endif
break;
case GAPM_CANCEL:
if(param->status != GAP_ERR_NO_ERROR) {
ASSERT_ERR(0); // unexpected error
}
break;
default:
ASSERT_ERR(0); // unexpected error
break;
}
return (KE_MSG_CONSUMED);
}
示例9: gatt_write_char_rsp_handler
/**
****************************************************************************************
* @brief Handles reception of the @ref GATT_WRITE_CHAR_RESP message.
* @param[in] msgid Id of the message received.
* @param[in] param Pointer to the parameters of the message.
* @param[in] dest_id ID of the receiving task instance.
* @param[in] src_id ID of the sending task instance.
* @return If the message was consumed or not.
****************************************************************************************
*/
static int gatt_write_char_rsp_handler(ke_msg_id_t const msgid,
struct gatt_write_char_resp const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
// Get the address of the environment
struct cscpc_env_tag *cscpc_env = PRF_CLIENT_GET_ENV(dest_id, cscpc);
if (cscpc_env != NULL)
{
ASSERT_ERR(cscpc_env->operation != NULL);
// Retrieve the operation currently performed
uint8_t operation = ((struct cscpc_cmd *)cscpc_env->operation)->operation;
switch (operation)
{
case (CSCPC_CFG_NTF_IND_OP_CODE):
{
// Send the complete event status
cscpc_send_cmp_evt(cscpc_env, operation, param->status);
} break;
case (CSCPC_CTNL_PT_CFG_WR_OP_CODE):
{
if (param->status == PRF_ERR_OK)
{
// Start Timeout Procedure
ke_timer_set(CSCPC_TIMEOUT_TIMER_IND, dest_id, CSCPC_PROC_TIMEOUT_TIMER_VAL);
// Wait for the response indication
((struct cscpc_cmd *)cscpc_env->operation)->operation = CSCPC_CTNL_PT_CFG_IND_OP_CODE;
}
else
{
// Send the complete event status
cscpc_send_cmp_evt(cscpc_env, operation, param->status);
}
} break;
default:
{
ASSERT_ERR(0);
} break;
}
}
// else ignore the message
return (KE_MSG_CONSUMED);
}
示例10: usr_init
/**
****************************************************************************************
* @brief User initialize
****************************************************************************************
*/
void usr_init(void)
{
if(KE_EVENT_OK != ke_evt_callback_set(EVENT_BUTTON1_PRESS_ID,
app_event_button1_press_handler))
{
ASSERT_ERR(0);
}
//register event callback for accelerometer interrupt
if(KE_EVENT_OK != ke_evt_callback_set(EVENT_ACCEL_INT_ID,
app_event_accel_handler))
{
ASSERT_ERR(0);
}
//PROTOCOL
//testing protocol
char *data;
data = malloc(sizeof(char)*14);
data[0] = 0x00;//PROTOCOL_COMMAND_ENABLE;
data[1] = 0x00;//PROTOCOL_BATT;
data[2] = 0x00;//PROTOCOL_COMMAND_ENABLE;
data[3] = 0x00;//PROTOCOL_TEMP;
data[4] = 0x00;//PROTOCOL_COMMAND_ENABLE;
data[5] = 0x00;//PROTOCOL_PED;
//data[4] = PROTOCOL_COMMAND_ENABLE;
//data[5] = PROTOCOL_PED;
//data[6] = 0x00;//PROTOCOL_COMMAND_ENABLE;
//data[7] = 0x00;//PROTOCOL_DISTANCE;
//for testing streaming ADC output set:
data[6] = PROTOCOL_COMMAND_ENABLE;
data[7] = PROTOCOL_ADC_SAMPLE;
//data[6] = 0x00;//PROTOCOL_COMMAND_ENABLE;
//data[7] = 0x00;//PROTOCOL_ADC_SAMPLE;
data[8] = PROTOCOL_COMMAND_RATE;
data[9] = 100;
data[10] = 0x00; //4 int
data[11] = 0x00;
data[12] = 0x04;
data[13] = '\0';
receive_packet(13, data);
//print_list();
}
示例11: usr_init
/**
****************************************************************************************
* @brief User initialize
****************************************************************************************
*/
void usr_init(void)
{
if(KE_EVENT_OK != ke_evt_callback_set(EVENT_BUTTON1_PRESS_ID,
app_event_button1_press_handler))
{
ASSERT_ERR(0);
}
#if (FB_JOYSTICKS)
if(KE_EVENT_OK != ke_evt_callback_set(EVENT_ADC_KEY_SAMPLE_CMP_ID,
app_event_adc_key_sample_cmp_handler))
{
ASSERT_ERR(0);
}
#endif
}
示例12: app_db_init_func
/**
****************************************************************************************
* @brief Initialise the database.
*
* @return If database initialization completed.
****************************************************************************************
*/
bool app_db_init_func(void)
{
// Indicate if more services need to be added in the database
bool end_db_create = false;
// Check if another should be added in the database
if (app_env.next_prf_init < APP_PRF_LIST_STOP)
{
switch (app_env.next_prf_init)
{
default:
{
ASSERT_ERR(0);
} break;
}
// Select following service to add
app_env.next_prf_init++;
}
else
{
end_db_create = true;
}
return end_db_create;
}
示例13: uart_rec_error_isr
static void uart_rec_error_isr(void)
{
void (*callback) (uint8_t) = NULL;
// Reset RX parameters
uart_env.rx.size = 0;
uart_env.rx.bufptr = NULL;
// Disable RX interrupt
SetBits16(UART_IER_DLH_REG, ERBFI_dlh0, 0); // uart_rec_data_avail_setf(0);
// Reset RX FIFO
// uart_rxfifo_res_setf(1); @WIK commented
// Retrieve callback pointer
callback = uart_env.rx.callback;
if(callback != NULL)
{
// Clear callback pointer
uart_env.rx.callback = NULL;
// Call handler
callback(UART_STATUS_ERROR);
}
else
{
ASSERT_ERR(0);
}
}
示例14: gapc_cmp_evt_handler
/**
****************************************************************************************
* @brief Handles GAP controller command complete events.
*
* @param[in] msgid Id of the message received.
* @param[in] param Pointer to the parameters of the message.
* @param[in] dest_id ID of the receiving task instance (TASK_GAP).
* @param[in] src_id ID of the sending task instance.
*
* @return If the message was consumed or not.
****************************************************************************************
*/
int gapc_cmp_evt_handler(ke_msg_id_t const msgid,
struct gapc_cmp_evt const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
switch(param->operation) {
// reset completed
case GAPC_UPDATE_PARAMS:
if (ke_state_get(dest_id) == APP_PARAM_UPD) {
if ((param->status != CO_ERROR_NO_ERROR)) {
// it's application specific what to do when the Param Upd request is rejected
app_update_params_rejected_func(param->status);
}
else {
// Go to Connected State
ke_state_set(dest_id, APP_CONNECTED);
// if state is APP_CONNECTED then the request was accepted
app_update_params_complete_func();
}
}
break;
default:
if(param->status != GAP_ERR_NO_ERROR) {
ASSERT_ERR(0); // unexpected error
}
break;
}
return (KE_MSG_CONSUMED);
}
示例15: app_entry_point_handler
int app_entry_point_handler (ke_msg_id_t const msgid,
void const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
int i=0;
enum ke_msg_status_tag process_msg_handling_result;
while (i<sizeof(app_process_handlers)/sizeof(process_event_func_t))
{
ASSERT_ERR(app_process_handlers[i]);
if (app_process_handlers[i](msgid,param,dest_id,src_id, &process_msg_handling_result)==PR_EVENT_HANDLED)
return (process_msg_handling_result);
i++;
}
//user cannot do anything else than consume the message
if (app_process_catch_rest_cb!=NULL)
{
app_process_catch_rest_cb(msgid,param,dest_id,src_id);
}
return (KE_MSG_CONSUMED);
};