Movesense,以毫秒为单位的系统时间
Movesense, system time in milliseconds
在 Movesense 平台上获取当前时间(以毫秒为单位)的正确方法是什么?
在模拟器环境中,ftime
工作正常,但 link
到 dfu
二进制(对 ftime
的未定义引用):
struct time t_start;
ftime(& t_start)
我也试了这个,但是没找到合适的时间:
struct timeval te;
gettimeofday(&te, NULL); // get current time
请记住,您使用的是嵌入式设备,并非所有功能都可用
gettimeofday() 是 CTIME 的一部分,可能在 movesense 上不可用,除非您或 Movesense 团队已为此平台实施它。
要获取设备时间,请使用 Movesense 团队提供的time API。
启动模块时
whiteboard::ResourceId mTimeResourceId;
getResource("Time",mTimeResourceId); // this returns a status HTTP status code
然后当你想要的时候用:
asyncGet(mTimeResourceId);
然后可以这样收集响应。
void OverskuddService::onGetResult(whiteboard::RequestId requestID,
whiteboard::ResourceId resourceId,
whiteboard::Result resultCode,
const whiteboard::Value& rResultData)
{
switch(resourceId.localResourceId)
{
case WB_RES::LOCAL::TIME::LID:
{
if(resultCode == wb::HTTP_CODE_OK)
{
int64_t currentTime = rResultData.convertTo<int64_t>();
}
}
}
}
这 returns 自 1970 年以来的微秒数,因此通过除以 1000 转换为毫秒。
此外,请注意,如果在取出电池或芯片进入睡眠模式时未设置时钟,时钟将设置为 2015.01.01。
请注意,不同服务的时间戳不同,ms 来自 epoch,us 来自 epoch seconds from epoch 等。
编辑:
正如 user1987093(我认为是为 Movesense 团队工作)所提到的,您还可以通过向 /Time/Detailed 发出 GET 请求来获取其他信息,这给出了当前的 UTC 时间 [us ], RelativeTime 即。时间戳 [自重置后的毫秒数](与传感器服务中的时间戳相同)、分辨率 [每秒滴答数] 以及精度 [ppm]
在 Movesense 平台上获取当前时间(以毫秒为单位)的正确方法是什么?
在模拟器环境中,ftime
工作正常,但 link
到 dfu
二进制(对 ftime
的未定义引用):
struct time t_start;
ftime(& t_start)
我也试了这个,但是没找到合适的时间:
struct timeval te;
gettimeofday(&te, NULL); // get current time
请记住,您使用的是嵌入式设备,并非所有功能都可用
gettimeofday() 是 CTIME 的一部分,可能在 movesense 上不可用,除非您或 Movesense 团队已为此平台实施它。
要获取设备时间,请使用 Movesense 团队提供的time API。
启动模块时
whiteboard::ResourceId mTimeResourceId;
getResource("Time",mTimeResourceId); // this returns a status HTTP status code
然后当你想要的时候用:
asyncGet(mTimeResourceId);
然后可以这样收集响应。
void OverskuddService::onGetResult(whiteboard::RequestId requestID,
whiteboard::ResourceId resourceId,
whiteboard::Result resultCode,
const whiteboard::Value& rResultData)
{
switch(resourceId.localResourceId)
{
case WB_RES::LOCAL::TIME::LID:
{
if(resultCode == wb::HTTP_CODE_OK)
{
int64_t currentTime = rResultData.convertTo<int64_t>();
}
}
}
}
这 returns 自 1970 年以来的微秒数,因此通过除以 1000 转换为毫秒。
此外,请注意,如果在取出电池或芯片进入睡眠模式时未设置时钟,时钟将设置为 2015.01.01。
请注意,不同服务的时间戳不同,ms 来自 epoch,us 来自 epoch seconds from epoch 等。
编辑: 正如 user1987093(我认为是为 Movesense 团队工作)所提到的,您还可以通过向 /Time/Detailed 发出 GET 请求来获取其他信息,这给出了当前的 UTC 时间 [us ], RelativeTime 即。时间戳 [自重置后的毫秒数](与传感器服务中的时间戳相同)、分辨率 [每秒滴答数] 以及精度 [ppm]