Hi,

This has got me puzzled. At the Wimborne Model Town we've been implementing an enhancement to the Pi-based Underground Railway Controller. As part of the system, there are some test scripts specifically designed to test the hardware (eg, Traffic Light control and track sensors, etc). The enhancement was designed to add a Status Panel, fitted at the rear of the layout, to enable operators to know what was going on.

To support the new Status Panel, I enhanced an existing script to include code to exercise all the LEDs on the panel. However, when I run this script in the target Pi, only the first section is executed and the script appears to 'leap across' many lines of code to the 'try' statement at the end of the script which says:


def led_cycle():
    traffic_lights()
    location_lights()
    sensor_lights()

    print("End of cycle")


def destroy():
    GPIO.cleanup()           # Release resource

if __name__ == '__main__':   # Program start from here
    try:
        while True:
            led_cycle()

    except KeyboardInterrupt:
        destroy()

In actual fact only the function traffic_lights() is executed, and once that is completed execution starts at the beginning of traffic_lights() again. No exceptions are trapped (I wouldn't know what to test for) and no errors or warnings are issued by the script.

The description above relates what happens when the script is run on the target machine, which is a Rasberry Pi Zero with the code in a writable partition. The partition containing /boot and / is set to read-only using a script that I download around five years ago for the original installation. The idea of this was to minimise the risk of uncontrolled shutdowns damaging the SD Card because the Model Railway Room environment didn't really allow for operators to do the job properly. This worked fine for some years before the old railway team removed the system in favour of a commercial one (which actually had less features).

However, if I run the same script on a Raspberry Pi 3 running the full PiOS desktop (and no read-only root), it works!

Any thoughts?  (Sorry about the long rambling explanation.)

--
Terry Coles


--
 Next meeting: Online, Jitsi, Tuesday, 2025-05-06 20:00
 Check to whom you are replying
 Meetings, mailing list, IRC, ...  https://dorset.lug.org.uk
 New thread, don't hijack:  mailto:[email protected]

Reply via email to