Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

UART not enabled after program terminates due to exception
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

UART not enabled after program terminates due to exception

by jasonthenderson on Mon Feb 24, 2020 12:05 am

I'm running code based on the CircuitPython 5 example here: https://learn.adafruit.com/circuitpytho ... tton-press on a CircuitPlayground BlueFruit and occasionally my program terminates with an exception (usually failing to allocate memory after a number of iterations). The Bluetooth stack seems to come back up as I can see it advertised in the BlueFruit Connect app. However, it seems like UART is stuck in a bad state as it never shows 'uart enabled' in the app and as a result can't use the command interface. I can remedy by resetting or killing the power and powering back up, but I'd really like to just have the program restart after the exception and continue on without having to reset as the device isn't easy to get to. Any ideas?

jasonthenderson
 
Posts: 12
Joined: Sat Jul 20, 2019 1:12 pm

Re: UART not enabled after program terminates due to excepti

by adafruit_support_carter on Mon Feb 24, 2020 2:05 pm

You can try using a try/except block to catch the exception and then just continue with code execution.

adafruit_support_carter
 
Posts: 17155
Joined: Tue Nov 29, 2016 2:45 pm

Re: UART not enabled after program terminates due to excepti

by jasonthenderson on Mon Feb 24, 2020 3:06 pm

Yes, I could do that. I was hoping that by letting the exception raise all the way up to the top that the soft reset would free up all assigned memory and let things run again for a while until memory got too fragmented. Note, I also see the same behavior of the UART not initializing if I call sys.exit() directly from code.

jasonthenderson
 
Posts: 12
Joined: Sat Jul 20, 2019 1:12 pm

Please be positive and constructive with your questions and comments.