On 02/05/2026 11:16, Ralph Corderoy wrote:
An alternative method, if you end up re-working this section:

     deadline = time.time() + sensor_test_time_out
     while time.time() < deadline:
         if GPIO.input(sensor_b):
             break

         time.sleep(sensor_pause_time)

Removes one variable, and it copes with creep though will still run past
deadline on the final iteration.

If the loop should execute at least once, then there's the explicit:

     deadline = time.time() + sensor_test_time_out
     while True:
         if GPIO.input(sensor_b):
             break
         if time.time() >= deadline:
             break

         time.sleep(sensor_pause_time)
Thanks for that, I'll keep that in mind.
It may be worth checking the code, or at least a fragment of it with the
GPIO logic, away from the main hardware so you can manually alter the
GPIO pin's value to debug the logic.

That's exactly what I am currently doing.  However, when I created the most recent version of the code (about a year ago), it seems that I wrote it to a much larger SD Card (I probably only had a 32 GB card to hand at the time.  As a result the image won't fit on the 8 GB cards I now have.  To add to my woes, the previous version to that will fit on 8 GB, but was written using a read-only file system.  I abandoned that last year, because it made debugging almost impossible.

I think I'll have to rebuild the whole system using the most recent RPi OS and write it all to a new card.  That won't hurt and I can't do much more until next week anyway.

--
Terry Coles


--
 Next meeting: Online, Jitsi, Tuesday, 2026-05-05 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