int msgQInfoPrint(MSG_Q_ID pMsgQ) { int i,pPendTasks[4]; char *pStr; memset(&MsgQinfo,0,sizeof(MsgQinfo)); MsgQinfo.taskIdListMax = 4; MsgQinfo.taskIdList = &pPendTasks[0]; MsgQinfo.msgListMax = 4; MsgQinfo.msgPtrList = &msgList[0]; MsgQinfo.msgLenList = &msgLenList[0]; msgQInfoGet(pMsgQ,&MsgQinfo); printf("%d Msge Queued, %d Limit, %d (bytes) Msge Size Limit\n", MsgQinfo.numMsgs,MsgQinfo.maxMsgs,MsgQinfo.maxMsgLength); if (MsgQinfo.numMsgs == 0) pStr = "Pending to get from MsgQ"; else if (MsgQinfo.numMsgs == MsgQinfo.maxMsgs) pStr = "Pending to put into MsgQ"; if (MsgQinfo.numTasks > 0) { for(i=0;i < MsgQinfo.numTasks; i++) { printf("Task: '%s' - 0x%lx is %s \n",taskName(pPendTasks[i]),pPendTasks[i],pStr); } } else { printf("No Task(s) Pending on this msgQ\n"); } return(0); }
STATUS msgQShow( MSG_Q_ID msgQId, int mode ) { STATUS status; MSG_Q_INFO info; TCB_ID tcbId; char tmpString[15]; int level; int taskIdList[20], taskDList[20]; char *msgPtrList[20]; int msgLengthList[20]; int i, j, len; char *pMsg; /* Clear info */ memset(&info, 0, sizeof(info)); /* If mode ge. 1 */ if (mode >= 1) { /* Get info for each message, task pending */ info.taskIdList = taskIdList; info.taskIdListMax = NELEMENTS(taskIdList); info.msgPtrList = msgPtrList; info.msgLengthList = msgLengthList; info.msgListMax = NELEMENTS(msgPtrList); } /* Lock interrupts */ INT_LOCK(level); /* Get message queue info structure */ status = msgQInfoGet(msgQId, &info); if (status != OK) { INT_UNLOCK(level); printf("Invalid message queue id: %#x\n", (int) msgQId); } else { /* If show tasks pending */ if ((info.numTask > 0) && (mode >= 1)) { /* For all in id list */ for (i = 0; i < min(info.numTask, NELEMENTS(taskIdList)); i++) { /* Get tcb */ tcbId = (TCB_ID) taskIdList[i]; if (tcbId->status & TASK_DELAY) { taskDList[i] = Q_KEY(&tickQHead, &tcbId->tickNode, 1); } else { taskDList[i] = 0; } } } /* Unlock interrupts */ INT_UNLOCK(level); /* Get options string */ if ((info.options & MSG_Q_TYPE_MASK) == MSG_Q_FIFO) { strcpy(tmpString, "MSG_Q_FIFO"); } else { strcpy(tmpString, "MSG_Q_PRIORITY"); } /* Print summary */ printf("\n"); printf("Message Queue Id : 0x%-10x\n", (int) msgQId); if ((info.options & MSG_Q_TYPE_MASK) == MSG_Q_FIFO) { printf("Task Queuing : %-10s\n", "FIFO"); } else { printf("Task Queuing : %-10s\n", "PRIORITY"); } printf("Message Byte Len : %-10d\n", info.maxMsgLength); printf("Messages Max : %-10d\n", info.maxMsg); printf("Messages Queued : %-10d\n", info.numMsg); if (info.numMsg == info.maxMsg) { printf("Senders Blocked : %-10d\n", info.numTask); } else { printf("Receivers Blocked : %-10d\n", info.numTask); } printf("Send timeouts : %-10d\n", info.sendTimeouts); printf("Receive timeouts : %-10d\n", info.reciveTimeouts); printf("Options : 0x%x\t%s\n", info.options, tmpString); /* If detailed info requested */ if (mode >= 1) { /* If tasks pending */ if (info.numTask > 0) { /* Get sender/receiver string */ if (info.numMsg == info.maxMsg) { strcpy(tmpString, "Senders"); } else { strcpy(tmpString, "Receivers"); } printf("\n%s Blocked:\n", tmpString); printf(" NAME TID PRI TIMEOUT\n"); printf("---------- -------- --- -------\n"); /* For all tasks */ for (i = 0; i < min(info.numTask, NELEMENTS(taskIdList)); i++) { printf( "%-11.11s%8x %3d %7u\n", taskName(taskIdList[i]), taskIdList[i], ((TCB_ID) taskIdList[i])->priority, taskDList[i] ); } } /* If messages pending */ if (info.numMsg > 0) { printf( "\nMessages queued:\n" " # address length value\n" ); /* For all messages */ for (i = 0; i < min(info.numMsg, NELEMENTS(msgPtrList)); i++) { /* Get message and length */ pMsg = msgPtrList[i]; len = msgLengthList[i]; printf("%3d %#10x %4d ", i + 1, (int) pMsg, len); /* For length */ for (j = 0; j < min(len, 20); j++) { if ((j % 4) == 0) { printf(" 0x"); } printf("%02x", pMsg[j] & 0xff); } if (len > 20) { printf(" ..."); } printf("\n"); } } } printf("\n"); } return status; }