Skip to content
Discussion options

You must be logged in to vote

The main thing to note about coroutines, is that they're not "true" preemptive threads, like you might see in other languages. You can't actually have multiple coroutines at once - instead you switch between coroutines using coroutine.resume (which resumes a coroutine) or coroutine.yield (which stops running this coroutine and returns to whichever one ran coroutine.resume).

This means when you call coroutine.resume(caller), you run your coroutine until the first os.pullEvent("modem_message"), but after that it's never run again - hence the loop no longer running!

The trick here is to put both loops inside their own coroutines, and then have a loop which pulls events and feeds them into bo…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@git-oykko
Comment options

Answer selected by git-oykko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants