is pycom.rgbled thread safe?
-
I modified the Pycom AWS MQTT library and put an LED blink into the transmit routine:
self._out_packet_mutex.acquire() if self._ping_failures == 0: if self._out_packet_mutex.locked() and len(self._output_queue) > 0: packet=self._output_queue[0] pycom.rgbled(0xff0000) # red if self._send_packet(packet): self._output_queue.pop(0) if self.wdt is not None: self.wdt.feed() pycom.rgbled(0x000010) # dark blue self._out_packet_mutex.release()Also, I feed the WDT here so the Wipy gets a reset in case of a connection loss. As the MQTT library starts a thread for this transmit routine and I also set the LED from the main code (running in parallel), could there be the case that the main code is interrupted while executing a pycom.rgbled and then pycom.rgbled be called in the transmit thread? Is it safe to do so? Or would I need to encapsulate the LED update with another mutex?
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login