【問題描述】函數
最開始contiki OS運行正常,rtimer定時打印出消息。後面修改代碼,將s_stRTimer.func = temp_func;改成了s_stRTimer.func = NULL;以後,ui
【問題處理】spa
將.func屬性賦爲有效函數;code
void test_StartTimer(uint16_t wMs) { uint16_t wCount; s_stRTimer.func = temp_func; /* Conver millisecond to Hz of rtimer */ wCount = (uint32_t)wMs * RTIMER_ARCH_SECOND / 1000; HAL_UART_Transmit(&huart2, "rtimer set\r\n", strlen("rtimer set\r\n"), 50); /* Set rtimer as well as start it! */ rtimer_set(&s_stRTimer, RTIMER_NOW() + wCount, 0, s_stRTimer.func, NULL); return; } void temp_func() { HAL_UART_Transmit(&huart2, "xxx\r\n", strlen("xxx\r\n"), 10); }
【小結】it
據此推斷:使用Contiki OS之rtimer時,不能將struct rtimer s_stRTimer的.func屬性設置爲NULL。class