OpenRoberta / robertalab-ev3dev

roberta lab connector for ev3dev
Apache License 2.0
17 stars 14 forks source link

Timer does not work #46

Closed afgym-baeu closed 6 years ago

afgym-baeu commented 7 years ago

Using any of the timer blocks leads to an error on the EV3 (both ev3dev and ev3lejos). With ev3dev this error message is shown on the bricks display (just using a reset timer 1 block:

Fehler im EV3 KeyError 1

Press any key

The digit in the third line equals the timer number the block referres to. Same issue on ev3lejos, but no error message is shown - the program simply crashes.

afgym-baeu commented 6 years ago

Initialisation works by now, but time.clock() should return a floating point value in seconds instead of a time in milliseconds, therefore the timer is still useless. The timer value shows strange values on my ev3. This program screenshot shows the floating point value starting at 0.000... increasing by only approx 0.05 per second!

afgym-baeu commented 6 years ago

replacing every call to time.clock() by int(round(time.time()*1000)) in ev3.py seems to work.

ensonic commented 6 years ago

Thanks for retesting. Could you please send the change as a PR (let me know if you need help)? But I think we want to stick to use time.clock(), but divide the returned value by 1000.0. That is in https://github.com/OpenRoberta/robertalab-ev3dev/blob/develop/roberta/ev3.py#L596 we change

- return time.clock() - self.timers[timer]
+ return int((time.clock() - self.timers[timer]) / 1000.0)

Also if you don't mind, please export your program and share the xml (e.g. attaching here or paste them on https://gist.github.com/).

afgym-baeu commented 6 years ago

50 is the new PR, I hope it is created the right way.

The program is on gist, because I can not attach an XML file here (as a ZIP it would be possible but gist seemed easier to me). time.clock() returns strange values on the EV3 and can not be used for this purpose IMHO.