05-11-2021, 06:41 AM
(05-11-2021, 06:11 AM)Andy--- Wrote: Great, this looks like an adventure, and I love adventures. Lets see how far I get
In case of success, how long should the log be?
Good question!
It is a binary file that grows by roughly 500 bytes for every ten seconds the HR monitor program is running (it stores the data every time the BPM field at the top is updated).
It is just a collection of records delimited by header so if you pass the file through a hexdump you should see the header:
0xffff:
YYYY (year, 16-bit)
MMMM (month, 16-bit)
DDDD (day, 16-bit)
hhhh (hour, 16-bit)
mmmm (minute, 16-bit)
ssss (seconds, 16-bit)
Note the header was constructed for convenience of writing rather then efficient packing. Also all those zeros make it easy to resync on the data if we get lost processing it. Anyhow after each header is 480 bytes of raw data (e.g. 240 16-bit samples exactly as they are read from the sensor) except for the first set of samples which could be any length from 1 to 240.
Note that it is impossible to read 0xffff from the sensor so you can just read the raw HR data until you get 0xffff and you will know you just found a new header.