/* * This function is used to flush the contents of the message queue. */ extern uint8_t msgQFlush ( MSG_Q_ID msgQId /* a pointer to the event control block associated with the desired queue */ ) { return OSQFlush(msgQId); }
void network_gm_reset(void) { INT8S res = 0; // INT8U err; gd_msg_t *send_msg = NULL; res = gprsmodule_reset(); gd_msg_malloc(&send_msg); send_msg->data = (void*)NULL; if(res == 0) { fail_tick = 0; send_msg->type = GD_MSG_GM_INIT; OSQPost(gd_system.network_task.q_network, (void*)send_msg); } else { fail_tick++; if(fail_tick >= NETWORK_FAIL_COUNT) { fail_tick = 0; OSQFlush(gd_system.network_task.q_network); //system reset system_reset(); } else { send_msg->type = GD_MSG_GM_RESET; } OSQPost(gd_system.network_task.q_network, (void*)send_msg); } }
//======================================================== //Function Name:msgQFlush //Syntax: void msgQFlush(MSG_Q_ID msgQId) //Purpose: flush message queue //Note: //Parameters: MSG_Q_ID msgQId //Return: //======================================================= void msgQFlush(MSG_Q_ID msgQId) { MSG_Q_LOCK(); OSQFlush(msgQId->pEvent); gp_memset( (INT8S *)msgQId->pMsgPool, 0, msgQId->maxMsgs * (msgQId->maxMsgLength + 4) ); MSG_Q_UNLOCK(); }
void main (void) { PC_DispClrScr(DISP_FGND_WHITE + DISP_BGND_BLACK); /* Clear the screen */ OSInit(); /* Initialize uC/OS-II */ PC_DOSSaveReturn(); /* Save environment to return to DOS */ PC_VectSet(uCOS, OSCtxSw); /* Install uC/OS-II's context switch vector */ RandomSem = OSSemCreate(1); /* Random number semaphore */ MSGQ = OSQCreate(MSGQGrp, N_TASKS); OSQFlush(MSGQ); OSTaskCreate(TaskStart, (void *)0, &TaskStartStk[TASK_STK_SIZE - 1], 0); OSStart(); /* Start multitasking */ }
/* Deallocates a mailbox. If there are messages still present in the mailbox when the mailbox is deallocated, it is an indication of a programming error in lwIP and the developer should be notified. */ void _sys_mbox_free(sys_mbox_t *mbox) { u8_t ucErr; LWIP_ASSERT( "sys_mbox_free ", *mbox != SYS_MBOX_NULL ); //clear OSQ EVENT OSQFlush( (*mbox)->pQ ); //del OSQ EVENT (void)OSQDel( (*mbox)->pQ, OS_DEL_NO_PEND, &ucErr); LWIP_ASSERT( "OSQDel ", ucErr == OS_ERR_NONE ); //put mem back to mem queue ucErr = OSMemPut( pQueueMem, (*mbox) ); LWIP_ASSERT( "OSMemPut ", ucErr == OS_ERR_NONE ); }
/* Deallocates a mailbox. If there are messages still present in the mailbox when the mailbox is deallocated, it is an indication of a programming error in lwIP and the developer should be notified. */ void sys_mbox_free(sys_mbox_t mbox) { u8_t ucErr; LWIP_ASSERT( "sys_mbox_free ", mbox != SYS_MBOX_NULL ); /* clear OSQ EVENT */ OSQFlush( mbox->pQ ); /* del OSQ EVENT */ (void)OSQDel( mbox->pQ, OS_DEL_NO_PEND, &ucErr); LWIP_ASSERT( "OSQDel ", ucErr == OS_ERR_NONE ); /* put mem back to mem queue */ ucErr = OSMemPut( pQueueMem, mbox ); LWIP_ASSERT( "OSMemPut ", ucErr == OS_ERR_NONE ); }
void network_tcpip_mode(void) { INT8S res = 0; INT8U err; gd_msg_t *send_msg = NULL; OSSemPend(gd_system.gm_operate_sem, GD_SEM_TIMEOUT, &err); if(err != OS_NO_ERR) res = -1; else res = gprs_tcpip_mode_init(0x01); OSSemPost(gd_system.gm_operate_sem); gd_msg_malloc(&send_msg); send_msg->data = (void*)NULL; if(res == 0) { fail_tick = 0; gd_system.state = GD_STATE_STANDBY; send_msg->type = GD_MSG_TCP_CONNECT; OSQPost(gd_system.network_task.q_network, (void*)send_msg); } else { fail_tick++; if(fail_tick >= NETWORK_FAIL_COUNT) { fail_tick = 0; OSQFlush(gd_system.network_task.q_network); send_msg->type = GD_MSG_GM_RESET; } else { send_msg->type = GD_MSG_TCP_MODE_INIT; } OSQPost(gd_system.network_task.q_network, (void*)send_msg); } }
void key_msg_flush (void) { OSQFlush (os_q_key_msg); }
void flush_radio_queue(void) { static OS_ERR os_err; OSQFlush(&opQueue, &os_err); }
/** * reset uart read buffer */ void flushUARTBuffer() { OSQFlush(uartQsem); //reset msg que usefull for cleaning invalid data }