Bus & train departures display, take 2

Is there all the exception handling that’s needed in the micropython script?

The classic way to deal with these issues is a watchdog timer. If you don’t “feed” it, like in a lockup situation, it will reset the system. Logging is of course useful to debug the underlying issue.

@dannz yes, it has a lot of exception handling already built in, with some of the exceptions (like “out of memory”) triggering a reboot. But I want to monitor if there are any other exceptions that don’t get caught for some reason.

@Kyle it used to have a watchdog when it was running on ESP32, now it’s migrated to a RPi Pico the watchdog API was slightly different so it didn’t immediately work and I commented it out. But I will figure out how to re-enable it next time I’m at the space.

Ideally, this would also have some way to remote update it but I’ve not seen a standard way to do this in MicroPython, I might have to come up with something.

Use ‘try:’ ‘except:’ statements for each block of code and either display the exception or write it to a file. I often simply give each block a reference ‘e1’, ‘e2’ etc. and print that if an exception occurs- that locates which bit of code is triggering an exception. With e.g. Selenium and retrieving information online, there can be problem making a connection and getting the data. That throws an exception, so simply retry, or ignore it and let the loop continue.

Took a while, but I was back in the space today and tried to make it more robust.

It’s got a watchdog timer now, so it’s really unlikely that it will ever hang completely.

In the unlikely event that this still happens somehow, the board is set up to regularly ping http://healthchecks.io so I’ll at least get an alert.

I also realised that my code has grown in a slightly chaotic way (mixing both data fetching and UI updates in a single loop) and it could probably benefit from being turned into some more async Micropython. But that’s a task for next time.

5 Likes

Nice work!

I really love this thing! It’s a brilliant creation.

Yes, and genuinely useful. Great work @futureshape

Indeed; as someone not overly-endowed with IT skills, I think it’s marvellous. At the risk of spouting hyperbole, I think this project embodies both the skills/ingenuity and the community spirit within SLMS.

1 Like