1

I am trying to create a media panel program that displays a picture slideshow. The codes uses pygame to load and display the images.

The Pi will lock up about an hour or so into the runtime and will not respond to any input. The green LED for ACT is solid green during this lock up and blinking during normal use.

I have tried to monitor the memory usage of this program and it remained constant. I have also tried to encapsulate different bits in try except blocks to catch any exceptions with no luck.

Does anyone have any insight into what is causing the lock up?

Current code:

# This program is a media panel program with the following functions:
# digital picture frame (WIP)
import pygame, os, datetime, time, random, settingsPictureFrame, logging
from os.path import isfile, join

logging.basicConfig(filename='mediaPanel.log',level=logging.DEBUG)

pygame.init()
pygame.mouse.set_visible(False)

# could move these to the settings file
width = 1920
height = 1080

size = (width, height)
timeValid = False
processRunning  = False

screen = pygame.display.set_mode(size,pygame.FULLSCREEN)

#allows shutdown of media panel
def waitDuration(seconds):

        running = True

        start_ticks = pygame.time.get_ticks()   #starting tick

        while (int(seconds) > (pygame.time.get_ticks()-start_ticks)/1000):

                time.sleep(1)

                if running == False:    break

                try:
                        for event in pygame.event.get():
                                if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
                                        running  = False
                                        pygame.mouse.set_visible(True)
                                        pygame.quit()

                except Exception as e:
                        logging.exception("message")


# load image files into list from directory
listFiles = [f for f in os.listdir(settingsPictureFrame.value['directoryImages']) if isfile(join(settingsPictureFrame.value['directoryImages'],f))]

while(True):

        # checks if the current time is within a valid time slot
        timeNow = datetime.datetime.now().time().strftime('%H:%M')
        dayNow = datetime.datetime.today().weekday()

        for i in range(0,len(settingsPictureFrame.timeSlot),3):

                if dayNow == int(settingsPictureFrame.timeSlot[i]) and timeNow >= settingsPictureFrame.timeSlot[i+1] and timeNow <= settingsPictureFrame.timeSlot[i+2]:

                        timeValid = True
                        break

                else:

                        timeValid = False

        if timeValid == True:

                if processRunning == False:

                        processRunning = True

                        # turn on screen 
                        #os.system('tvservice -p')
                        #os.system('fbset -depth 8 && fbset -depth 16')

                        image = pygame.image.load(settingsPictureFrame.value['directoryImages'] + random.choice(listFiles))

                        screen.blit(image,(0,0))

                        pygame.display.flip()   # display image


                else:

                        #logging
                        try:
                                image = pygame.image.load(settingsPictureFrame.value['directoryImages'] + random.choice(listFiles))

                                screen.blit(image,(0,0))

                                pygame.display.flip()   # display image

                        except Exception as e:
                                logging.exception("message")
                                logging.info('image load failed. terminated program')
                                pygame.quit()


        else:

                if processRunning == True:

                        processRunning = False

                        # turn off screen
                        #os.system('tvservice -o')

                        pygame.quit()

        waitDuration(settingsPictureFrame.value['durationImage'])
NinjaLlama
  • 167
  • 3
  • 14
  • How long is the lockup for? Does it repeat every 60 minutes? What else is running on the Pi? Does the same thing happen if you run the code on a different Pi? Does the Pi lockup every 60 minutes even when your code isn't running? – DisappointedByUnaccountableMod Jun 20 '16 at 06:27
  • The lockup is permanent, I waited and tried to access for around 30minutes. There should not be anything else running, I start the pi, then startx, then run the mediapanel.py via the python3 shell. I only have one Pi so I cannot try another, and I have left the Pi idle for about 6hours with nothing running and it did not lock up during that time. – NinjaLlama Jun 20 '16 at 12:14
  • 1
    ACT (green light) indicates SD card activity normally - can you try with a different SD card? If this is a Pi3 then you need a 2.5A power supply - PLUS whatever current your display needs, what is the amps rating of the PSU you are using? Also see http://elinux.org/R-Pi_Troubleshooting. If nothing else add a slew of logging.info() calls around all the flows through your code and see if there is a pattern to the last log message every time it locks up. – DisappointedByUnaccountableMod Jun 20 '16 at 17:01
  • I have another card that I can try out and see if it works. The Pi model B and the display are on separate power supplies at the moment. I'll also try the info calls again and see if I can get a pattern worked out. Thank you for the help. – NinjaLlama Jun 20 '16 at 18:03
  • I have switched SD cards and the Pi has been running for about two hours so far. I think the card might have been the issue because when I tried to clone the image it would fail about halfway through every time. Thank you again. – NinjaLlama Jun 23 '16 at 00:50
  • 1
    To anyone reading this after it was closed as [duplicate]. The issue was with the SD card because everything ran normally after changing to a new card. The "duplicate" questions are not relevant to what I was experiencing at the time. – NinjaLlama Jan 27 '21 at 00:44

0 Answers0