Contiki OS 中所有 运行 个进程的列表
List of all running processes in Contiki OS
是否可以os列出 contiki 运行 中的所有进程 os 并在调试输出(即 UART)上输出结果?
将此插入到 contiki platform.c 和 main() 中:
struct process *p;
uint8_t ps;
int n;
int
main(void) /*contiki main() here */
{
n=0;
while(1)
{
//...
//...
/*************************************************************/
if(n==100)
{
uint8_t ps=process_nevents();
PRINTF("there are %u events in the queue", ps);
PRINTF("\n\n");
PRINTF("Processes:");
for(p = PROCESS_LIST(); p != NULL; p = p->next)
{
char namebuf[30];
strncpy(namebuf, PROCESS_NAME_STRING(p), sizeof(namebuf));
PRINTF("%s", namebuf);
PRINTF("\n\n");
n=0;
}
}
n +=1;
/*********************************************************************/
//...
//...
}
return 0;
}
这将在主循环的每 100 次迭代中输出 运行 个进程
如果您使用 UART 作为调试端口,您必须通过 atmega128rfa1
将 PRINTF() 的输出重定向到正确的端口
/* Second rs232 port for debugging or slip alternative */
rs232_init(RS232_PORT_1, USART_BAUD_9600,USART_PARITY_NONE |
USART_STOP_BITS_1 | USART_DATA_BITS_8);
/* Redirect stdout */
/* #if RF230BB_CONF_LEDONPORTE1 || defined(RAVEN_LCD_INTERFACE) */
rs232_redirect_stdout(RS232_PORT_1);
contiki shell 源代码包含非常有用的命令,无需使用整个 shell 即可轻松用于调试,请参阅
http://anrg.usc.edu/contiki/index.php/Contiki_Shell
是否可以os列出 contiki 运行 中的所有进程 os 并在调试输出(即 UART)上输出结果?
将此插入到 contiki platform.c 和 main() 中:
struct process *p;
uint8_t ps;
int n;
int
main(void) /*contiki main() here */
{
n=0;
while(1)
{
//...
//...
/*************************************************************/
if(n==100)
{
uint8_t ps=process_nevents();
PRINTF("there are %u events in the queue", ps);
PRINTF("\n\n");
PRINTF("Processes:");
for(p = PROCESS_LIST(); p != NULL; p = p->next)
{
char namebuf[30];
strncpy(namebuf, PROCESS_NAME_STRING(p), sizeof(namebuf));
PRINTF("%s", namebuf);
PRINTF("\n\n");
n=0;
}
}
n +=1;
/*********************************************************************/
//...
//...
}
return 0;
}
这将在主循环的每 100 次迭代中输出 运行 个进程
如果您使用 UART 作为调试端口,您必须通过 atmega128rfa1
将 PRINTF() 的输出重定向到正确的端口/* Second rs232 port for debugging or slip alternative */
rs232_init(RS232_PORT_1, USART_BAUD_9600,USART_PARITY_NONE |
USART_STOP_BITS_1 | USART_DATA_BITS_8);
/* Redirect stdout */
/* #if RF230BB_CONF_LEDONPORTE1 || defined(RAVEN_LCD_INTERFACE) */
rs232_redirect_stdout(RS232_PORT_1);
contiki shell 源代码包含非常有用的命令,无需使用整个 shell 即可轻松用于调试,请参阅 http://anrg.usc.edu/contiki/index.php/Contiki_Shell