This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] LAUNCHXL-CC3235SF:CLOCK_settime 和 CLOCK_gettime 不工作

Guru**** 2482225 points
Other Parts Discussed in Thread: CC3235SF

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/wi-fi-group/wifi/f/wi-fi-forum/1288019/launchxl-cc3235sf-clock_settime-and-clock_gettime-not-working

器件型号:LAUNCHXL-CC3235SF
主题中讨论的其他器件:CC3235SF

您好!

尝试在我的项目上设置 RTC 和时间、但 CLOCK_gettime 出现了一些问题。 FreeRTOS 上运行。

似乎 timespec 正变得混乱,当我要求的时间,我在 ts 中预期的秒数在 ts 中显示。tv_sec。

下面是我正在运行的简单代码和看到的输出:

struct timespec ts = { 0, 0 };
ts.tv_sec = 1698861678;//Default timestamp
ts.tv_nsec = 0;
clock_settime(CLOCK_REALTIME, &ts);
UART_PRINT("TIME: %d - %d (errno: %d)\r\n", ts.tv_sec, ts.tv_nsec, errno);

while(1)
{
    sleep(1);
    clock_gettime(CLOCK_REALTIME, &ts);
    UART_PRINT("TIME: %d - %d (errno: %d)\r\n", ts.tv_sec, ts.tv_nsec, errno);
}

并具有以下输出:

TIME: 0 - 1698861678 (errno: 0)
TIME: 536986692 - 1698861679 (errno: 0)
TIME: 536986692 - 1698861680 (errno: 0)
TIME: 536986692 - 1698861681 (errno: 0)
TIME: 536986692 - 1698861682 (errno: 0)
TIME: 536986692 - 1698861683 (errno: 0)

不能确定从 ts.tv_sec 报告的数字是什么,但是时钟似乎工作但在 ts.tv_nsec 中报告?

我还在示例项目 network_terminal_CC3235SF_LAUNCHXL_freertos_ticlang 上尝试了此操作、我的项目所基于的是这个项目、并且具有相同的行为。

我们将从 MSP432P4111迁移至这一全新的 CC3235SF、因为它已停产、我已在该平台(TI-RTOS)上测试了与此代码完全相同的代码、而且它在运行时会表现出如下预期:

TIME: 1698861678 - 0 (errno: 0)
TIME: 1698861678 - 0 (errno: 0)
TIME: 1698861679 - 0 (errno: 0)
TIME: 1698861680 - 0 (errno: 0)
TIME: 1698861681 - 0 (errno: 0)

请告诉我你的想法!

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    它不是关于 clock_settime()-它是关于打印。

    您应该使用:

    uart_print ("time:%LLD -%LLD (errno:%d)\r\n "、ts.tv_sec、ts.tv_ns、0);

    因为 tv_sec 是 一个64b (超长整型)值(tv_nsec 是一个32b 值)。