You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to implement a blinking function for the on-board LED light in a Smart Hub (aka City Hub). I have the blink code running in a thread. By itself, it works fine. It just runs in an infinite loop, swapping the LED color in between two values, with a sleep delay in between changes. There are termination and status flags that help to manage the loop, stopping it and killing the thread under external command. All works as expected when running by itself.
But when I run other code (outside that thread) that also communicates with the hub, such as to command a motor in port A, there are apparently collisions in the messaging system in pylgbst. These happen at random, but more often the faster the blink rate goes, and eventually kill the entire thing.
Your code seem to violate its expectation of strictly one sync command running at a time. I did not block that from happening because there may be combination of sync and non-sync commands. So you can think of lib as non-thread-safe.
To overcome your issue, introduce a lock object that will be used to wrap the LED state change commands as well as other commands. You just need to wrap exact command invocations.
I am trying to implement a blinking function for the on-board LED light in a Smart Hub (aka City Hub). I have the blink code running in a thread. By itself, it works fine. It just runs in an infinite loop, swapping the LED color in between two values, with a sleep delay in between changes. There are termination and status flags that help to manage the loop, stopping it and killing the thread under external command. All works as expected when running by itself.
But when I run other code (outside that thread) that also communicates with the hub, such as to command a motor in port A, there are apparently collisions in the messaging system in pylgbst. These happen at random, but more often the faster the blink rate goes, and eventually kill the entire thing.
The errors I get are always of the type:
although the details of the error, such as port number and payload, may change from run to run.
Is there perhaps a way in pylgbst to get around this?
The text was updated successfully, but these errors were encountered: