Closed Mynogs closed 5 years ago
@Mynogs,
I have to review it, maybe it's something related to coroutines inside timers. As far I can understand inside sim.cycle you only toggle gpio5, right?
Also, remember that you can run Lua threads, mapped into FreeRTOS tasks using the Lua RTOS thread module. See:
https://github.com/whitecatboard/Lua-RTOS-ESP32/wiki/Thread-Module
@jolivepetrus I switch on the LED in sim.cycle(true) and off in sim.cycle(false). I used the thread construct because I can be happen that the simulation cycle lasts too long. I was not sure what happened to the timer. For me it is important that the simulation cycles are called at a fixed rate.
@Mynogs I tried to reproduce your issue but obviously the 'sim' object is missing. Can you provide the missing object's source code?
@Mynogs by the way, please check
if sim.cycle then
sim.cycle(false)
end
maybe you mean to have this:
if sim.cycle() then
sim.cycle(false)
end
I would expect sim.cycle
to always be true whereas sim.cycle()
would return the current state.
Sorry for the long delay!
if sim.cycle then sim.cycle(false) end
is correct! sim.cycle is a kind of hook function. If sim.cycle is nil no hook function for the busy time measurement is set. Mostly this hook function is use to handle the "busy" LED on the board. sim.cycle(true) switch on the LED and sim.cycle(false) switch the LED of.
As mentioned in https://github.com/whitecatboard/Lua-RTOS-ESP32/issues/258#issuecomment-509150158
@Mynogs I tried to reproduce your issue but obviously the 'sim' object is missing. Can you provide the missing object's source code?
A simplified version is fine, as long as that still triggers the error. Or can the code from https://github.com/whitecatboard/Lua-RTOS-ESP32/issues/287 be used?
@the0ne First, you can donwload the p+ simulation system from github: https://github.com/Mynogs/PPV2-Simulation-System And the ESP32 target injector and library: https://github.com/Mynogs/PPV2-ESP32
I can not reproduce the error on my current board. I think the mistake was that I used a floating point value as timing value. And lua_tointeger returns 0. Now I use math.floor to convert to integer, so the problem does not seem to occur anymore. I have not checked this in the source code of Lua-RTOS.
I think we can close the case. Thank you for your help!
I have tried to reproduce as well but didn't succeed. So I'm closing this issue as requested by @Mynogs
I have a very simple model for Lua board. I simply switch on and off GPIO5:
The main simulation loop looks like this:
Works fine!
I changed it to use a software timer:
Then I got this:
The debug print messages StepX shows, the fault occures in the second simulation step.