msoon / PyMonsoon

Monsoon Power Monitor Python Library
MIT License
55 stars 23 forks source link

Not returning the value that is documented #28

Open yusufm opened 5 years ago

yusufm commented 5 years ago

https://github.com/msoon/PyMonsoon/blob/369903074eff5f95c185bf4efd7b553212c8e136/Monsoon/sampleEngine.py#L538

The docstring states that if legacy_timestamp is set to True, then the value of time.time() is used. But in the code of the function (line 548), we see that actually the value is set to int(time.time()). This reduces the precision of the timestamp, since its being cast to int.

Also, if you remove the cast, it looks like there is some bad interaction with the packet data processing somewhere, where the value seems to be garbled.

Either we should actually use time.time(), which would provide much better precision, or change the documentation to reflect that we cast to int(), and also, why we do that.