nickovs / slimDNS

Simple, Lightweight Implementation of Multicast DNS
Apache License 2.0
86 stars 9 forks source link

time.ticks_diff and time.ticks_ms are undefined. #5

Open nevercast opened 5 years ago

nevercast commented 5 years ago

While effort has been made to support running outside of micropython, some non-standard functions are still used.

I've stubbed them like so:

import time
if not hasattr(time, 'ticks_ms'):
    ticks_ms = lambda : time.clock() * 1000.
else:
    ticks_ms = time.ticks_ms
if not hasattr(time, 'ticks_diff'):
    ticks_diff = lambda a, b: b - a
else:
    ticks_diff = time.ticks_diff

Then used ticks_diff() and ticks_ms() instead of time.ticks_diff() and time.ticks_ms() respectively.

I believe this is correct, you may want to verify ticks_diff's polarity.

nickovs commented 5 years ago

Thanks for the suggestion. As I mentioned in my first reply to #1 the main goal with slimDNS is minimal memory footprint when run on micropython, so I've been trying to avoid adding extra code like this. That said, if there is genuine interest in a version that runs on other platforms then I can look into it.

nevercast commented 5 years ago

My primary motivation was the simplicity of the design (read: lightweight), being able to test on Windows would allow me to validate if its the right thing that I need, as well as use it to detect micropython devices asking the question part of the server.