Persistent Button Unresponsiveness After Extended Run Time

Topics about the Software of Revolution Pi
Post Reply
Jow W.
Posts: 7
Joined: 11 Jun 2024, 10:09

Persistent Button Unresponsiveness After Extended Run Time

Post by Jow W. »

Hi everyone,

I'm using Revolution Pi Connect 4 to run a Python script that monitors push button inputs and triggers actions accordingly. The script runs smoothly for short periods, but often hangs after several hours (3-4 hours), making the buttons unresponsive. I've included the core part of my code below.

Code: Select all

def main():
    # initializing
    while True:
    	# Check whether a button has been pressed and execute the assigned action
        checkButtons(controlPanel, standAloneRack, autoMode)
        time.sleep(0.5)
Are there any known issues or settings I should adjust to prevent this behavior? I'm suspecting a resource leak or potential blocking operation within the checkButtons function. Any guidance would be greatly appreciated.

Joe
Why do programmers prefer dark mode?

Because the light attracts bugs! :lol:
u.biakoup
KUNBUS
Posts: 201
Joined: 14 Apr 2022, 13:04

Re: Persistent Button Unresponsiveness After Extended Run Time

Post by u.biakoup »

Hello Joe,
Let's go through a few potential troubleshooting steps and adjustments that might help identify or resolve the issue.

1. Investigate the checkButtons Function

Blocking Operations: If the checkButtons function contains any blocking operations (e.g., waiting for hardware response, long-running computations), these could cause the script to hang. Ensure that this function returns promptly, especially if it’s checking hardware inputs.
Error Handling: Make sure you have proper error handling within checkButtons. Unhandled exceptions could cause the loop to stop executing.

2. Memory and Resource Leaks

Memory Leaks: If the checkButtons function or any part of your script is gradually consuming more memory, it could eventually exhaust available resources, causing the script to hang. Use tools like psutil or monitor the system with top or htop to check if memory usage increases over time.
File Descriptors or Other Resources: If your script opens files or network connections, ensure they are properly closed after use.

3. Watchdog Timer

Watchdog Timer: Implement a watchdog timer or a similar mechanism that can restart the script or trigger an alert if the script fails to run within a specified time frame. This can help keep the system running even if it hangs.

4. System Monitoring
Monitor System Resources: Check CPU, memory, and I/O load during the script’s execution. If these increase over time, it could indicate a problem.

Temperature: Overheating can cause unexpected behavior in hardware. Ensure the device is operating within normal temperature ranges.

5. Review External Dependencies
Library Issues: If your code relies on external libraries or hardware drivers, ensure they are up-to-date and compatible with your system. Sometimes, bugs in these libraries can cause hangs.

6. Reboot or Restart Script Periodically
Periodic Restart: As a temporary workaround, you can implement a mechanism to restart the script or reboot the device at regular intervals, reducing the chances of long-term hangs.

7. Check for Kernel or Hardware Issues
Hardware Faults: If your hardware is faulty, it might cause intermittent hangs. Check if other systems with similar hardware exhibit the same issue.
Kernel Logs: Review system logs (/var/log/syslog, /var/log/kern.log) for any unusual messages that occur around the time the script hangs.

If you try these suggestions and the issue persists, it might help to share more details about the checkButtons function or any error messages you encounter. This would provide more insight into potential root causes.

Best Regards

Ulrich Kouatang Biakoup | field application engineer
Post Reply