Skip to content

Commit

Permalink
Improve native timestamping precision
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-rabault committed Aug 4, 2023
1 parent eaf25fc commit 5147762
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion engine/HAL/NATIVE/luos_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ uint64_t LuosHAL_GetTimestamp(void)
#else
clock_gettime(CLOCK_MONOTONIC, &time);
#endif
return time.tv_nsec;
volatile uint64_t timestamp = time.tv_nsec + time.tv_sec * 1000000000;
return timestamp;
}

/******************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion engine/core/inc/luos_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extern "C"
// *** Timestamping management (in file `timestamp.c`)***
time_luos_t Luos_Timestamp(void);
bool Luos_IsMsgTimstamped(const msg_t *msg);
time_luos_t Luos_GetMsgTimestamp(msg_t *msg);
time_luos_t Luos_GetMsgTimestamp(const msg_t *msg);
error_return_t Luos_SendTimestampMsg(service_t *service, msg_t *msg, time_luos_t timestamp);

// *** Pub/Sub management (in file `pub_sub.c`)***
Expand Down
2 changes: 1 addition & 1 deletion engine/core/src/timestamp.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ _CRITICAL inline bool Luos_IsMsgTimstamped(const msg_t *msg)
* @param msg : Message to get the timestamp from
* @return time_luos_t
******************************************************************************/
time_luos_t Luos_GetMsgTimestamp(msg_t *msg)
time_luos_t Luos_GetMsgTimestamp(const msg_t *msg)
{
LUOS_ASSERT(msg != NULL);
time_luos_t timestamp = {0.0f};
Expand Down

0 comments on commit 5147762

Please sign in to comment.