0
我想在Contiki中定期生成一些樣本。我用CTIMER生成它,如下所示:Contiki時鐘模塊不更新
PROCESS_THREAD(null_app_process, ev, data)
{
PROCESS_BEGIN();
printf("Sine Wave Started\n");
app_conn_open(&nullApp_callback);
if (node_id != 0)
{
ctimer_set(&ct,102,sample_fun,(void*)NULL);
}
PROCESS_END();
}
static void sample_fun(void)
{
int8_t data_buf[6] = {0};
uint8_t i;
for(i = 0; i < 6; i++)
{
data_buf[i] = sinI(counter);
counter++;
}
app_conn_send((uint8_t *)data_buf,6*sizeof(int8_t));
ctimer_reset(&ct);
}
然而,並不週期性地產生的樣品中,如從下面的日誌看出:
TDMA RDC: SN sends 52, 12 bytes 14202
0,165,16,
TDMA RDC: SN sends 53, 18 bytes 14458
0,166,16,
TDMA RDC: SN sends 54, 12 bytes 14714
0,167,16,
TDMA RDC: SN sends 55, 18 bytes 14970
0,168,16,
TDMA RDC: SN sends 56, 12 bytes 15226
0,169,16,
TDMA RDC: SN sends 57, 18 bytes 15482
0,170,16,
TDMA RDC: SN sends 58, 12 bytes 15738
0,171,16,
TDMA RDC: SN sends 59, 18 bytes 15994
0,172,16,
TDMA RDC: SN sends 60, 12 bytes 16250
0,173,16,
TDMA RDC: SN sends 61, 0 bytes 16257
0,174,16,
TDMA RDC: SN sends 62, 0 bytes 16257
0,175,16,
TDMA RDC: SN sends 63, 0 bytes 16257
0,176,16,
TDMA RDC: SN sends 64, 0 bytes 16257
0,177,16,
TDMA RDC: SN sends 65, 0 bytes 16257
0,178,16,
TDMA RDC: SN sends 66, 0 bytes 16257
0,179,16,
TDMA RDC: SN sends 67, 0 bytes 16257
0,180,16,
TDMA RDC: SN sends 68, 0 bytes 16257
0,181,16,
TDMA RDC: SN sends 69, 18 bytes 16506
0,182,16,
TDMA RDC: SN sends 70, 12 bytes 16762
0,183,16,
TDMA RDC: SN sends 71, 18 bytes 17018
0,184,16,
TDMA RDC: SN sends 72, 12 bytes 17274
0,185,16,
TDMA RDC: SN sends 73, 18 bytes 17530
當生成的樣品中,SN發送幾個字節。當樣本未生成時,SN發送零字節。行尾的數字是時鐘時間(clock_time())。看起來像沒有生成樣本時鐘時間沒有更新。因此,我懷疑時鐘模塊在某些情況下不會更新。有沒有人見過這個?如果是這樣,可以解釋原因?
哪個版本的Contiki?哪個硬件平臺?這個補丁可能是相關的:https://github.com/contiki-os/contiki/pull/727另一方面,它看起來像你的時鐘模塊停留時間超過2秒,所以還有其他一些問題。 – kfx 2014-08-28 09:41:08
@kfx謝謝!我認爲你的建議是正確的。 – cloudfarm 2014-08-28 15:55:32
很高興能有所幫助。 – kfx 2014-08-28 18:47:40