Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timer broken on hosted #387

Closed
strongly-typed opened this issue Apr 28, 2020 · 5 comments · Fixed by #389
Closed

Timer broken on hosted #387

strongly-typed opened this issue Apr 28, 2020 · 5 comments · Fixed by #389

Comments

@strongly-typed
Copy link
Collaborator

Consider this example on hosted/macOS:

#include <modm/debug/logger.hpp>
#include <modm/processing/timer.hpp>

using namespace std::chrono_literals;

modm::ShortTimeout timeout;

int
main()
{
	int ctr(0);
	timeout.restart(500ms);

	while(true)
	{
		if (timeout.isExpired()) {
			MODM_LOG_DEBUG << "ping " << ctr++ << modm::endl;
			timeout.restart(500ms);
		}
	}
}

It spit out numbers without delays.

Some code that deals with real world peripherals relies on that.

Probably related to #374. I'll do a bisect soon.

@strongly-typed
Copy link
Collaborator Author

strongly-typed commented Apr 28, 2020

Broke from commit f1021b0 to c63a536. I cannot compile the commits in between.
Same behavior observed on macOS and in a docker container with Debian.

@strongly-typed strongly-typed changed the title Timer broken on hosted / macOS Timer broken on hosted Apr 28, 2020
@salkinium
Copy link
Member

Maybe the cast from int64_t to uint32_t is not the best idea… I didn't even test this *shame*.

@salkinium
Copy link
Member

(can reproduce)

@salkinium
Copy link
Member

hm, it works with a modm::Timeout instead of a ShortTimeout, so I suspect issues with casting from uint32_t to uint16_t ms.

@salkinium
Copy link
Member

Yep, found the bug. I need to add some tests for this though…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants