Timestamp is a feature that enables you to track the date at which an event occurs. You can track as many events as you want, timing informations are saved in the system with the value associated to events.
Let's take an example with a button driver: each time we read the button state, we want to timestamp this event. First we have to create a global variable called a token, it's used to track our event in the system:
Then we can tag our data related to the button event with this token:
Timestamp_Tag links the token to the data. This enables several features:
- if you use button.state in an another function in your service, you can check if there is a timestamp linked to the data and get it from the token with Timestamp_GetToken and Timestamp_GetTimeFromToken functions.
- if you send button.state through a luos message, the timestamp will be copied in the message. Then you can get it from the message in the receiving service with the Timestamp_DecodeMsg function.
All timestamp API functions can be found in Luos/Robus/inc/timestamp.h. You can also find examples which are using this feature. For now, examples using timestamp are :
- light sensor
|Tag a data with a token|
|Get a token from a data|
|Check if a message is timestamped|
|Update the timestamp in a message|
|Encode a message with the timestamp protocol|
|Decode a timestamped message|