1

BrightScript problem

Hello, I encounter a problem with my brightscript plugin, the brightsign crashes and restarts completely.

in the log I have this error (that I can't find on the internet) :

"[ 145.444] Watchdog client 'BrightScript_0x7f3055e760' failed to prod in a timely manner."

Full log : http://pastebin.fr/69805

My script allows me during the display by BrightAuthor to trigger on an event (UDP or GPIO for example) a playback of the multimedia contained in a USB key.

The script "works" because the photos and videos are displayed on the screen but after a certain amount of time the brightsign crashes.

Here is my source code:

https://paste.ofcode.org/PZBWMu4egx898pxQphvpYk

Do you have an idea where this could come from ?

Thank you for your help.
I'm looking forward to hearing from you.

Translated with www.DeepL.com/Translator (free version)

20 comments

  • 0
    Avatar
    Bright Scripters

    Hi Greg, and thanks for sharing your code here. We always like a good riddle :)

    Seems like the watchdog detects that the plugin code, is not returning before the watchdog times-out.

    Watchdog client 'BrightScript_0x7f3055e760' failed to prod in a timely manner.

     
    Normally, you'd want to avoid loops such as the one found in the plugin code. If the video being played is longer than the watchdog period (1min by default), the player will reboot.
     
    while (true)
    msg = wait(60000, p)

    if type(msg)= "roVideoEvent" and msg.GetInt() = 8 then exit while
     
    end while
     
    Rather than waiting for the video to finish, you should listen to the roVideoEvent in the main event loop, inside
    Function USBPlayer_ProcessEvent()
     
    After media have ended, and roVideoEvent is detected, the next media file picked from the list.
     
    You'd want to become familiar with roList methods such as Push(), Next(), IsNext(), Reset(), Clear()
     
    I hope that helps
     
     
  • 0
    Avatar
    Greg

    Hello, thank you I understand better :)

    I'm afraid to completely revise my code for a result that doesn't work because it's misunderstood so I ask some questions ^^.

    ... if I understood correctly, I have to wait for "roVideoEvent" in "USBPlayer_ProcessEvent" like this :

    if type(event) = "roAssociativeArray" AND type(event["EventType"]) = "roVideoEvent" then ... play next in roList ?

    if I do like this, I have to prepare the roList when I start my "USBPlayer_ProcessEvent" function but is it kept if I quit the "USBPlayer_ProcessEvent" function ?

    if not, I can't do a :

    pluginMessageCmd["PluginMessage"] = "ImAlive"
    m.msgPort.PostMessage(pluginMessageCmd)

    Thanks :)

    Edit :

    i have made some test if i leave the function the video is not displayed any more ...

    And

    pluginMessageCmd["PluginMessage"] = "ImAlive"
    m.msgPort.PostMessage(pluginMessageCmd)

    In the "While(true)" loop not working too ... wtf i'm not understand what i have to do now

     

     

     

  • 0
    Avatar
    Bright Scripters

    Something like this

     

    Function USBPlayer_ProcessEvent(event As Object) as boolean
    print"USBPlayer process event"
     
    if type(event) = "roVideoEvent" then

    ' Handle next video here

    else if type(event) = "roAssociativeArray" then
     
    if type(event["EventType"]) = "roString" then
     
    etc...
     
    The rolist of media files can be populated during initialization, or upon message from the presentation
  • 0
    Avatar
    Greg

    Good evening and thank you for the answer.
    I tried to launch a video and exit the ProcessEvent but when I quit the function, the video also stops.

    So if I loop, it reboot and if I quit the function, the playback stops...

  • 0
    Avatar
    Bright Scripters

    The roVideoPlayer object must be created at a scope outside of the function, so when the function returns, the player's object is not destroyed.

    Looks like roVideoPlayer can play images too

    https://docs.brightsign.biz/display/DOC/roVideoPlayer#roVideoPlayer-PlayStaticImage(filenameAsString)AsBoolean

     

    I've updated the file on 

    https://paste.ofcode.org/PZBWMu4egx898pxQphvpYk

    Code is not tested, and would need more work for it to respond to plugin events from the presentation if needed.

  • 0
    Avatar
    Greg

    Thanks i think i understand.

    When you edit code on "paste.ofcode.org" then they make you a new url, the orginal link keep the original code.

    i have understand to i have to declare my RoVideoPlayer in the plugin object like this :

    Function newUSBPlayer(msgPort As Object, userVariables As Object, bsp as Object)
      print "newUSBPlayer"
      p = {}
      p.version = 1.0
      p.msgPort = msgPort
      p.userVariables = userVariables
      p.bsp = bsp
      p.debug  = false
      p.objectName = "USBPlayer_object"
      p.ProcessEvent = USBPlayer_ProcessEvent

    p.player = CreateObject("roVideoPlayer")
    p.player.setport = msgPort

    return p
    End Function

    there is any way to gets an event after display picture with "PlayStaticImage" ?
    Because if I have 40 images displayed of 6 seconds each with sleep the BrightSign will also reboot ...

    Thanks a lot anyway for the help it's great :)

  • 0
    Avatar
    Greg

    Thanks a lot it's Working fine !

    my code :

    https://paste.ofcode.org/XLDBdFvxHAiyDWCrBimJCk

    I have use PlayStaticImage with sleep and an SEND_PLUGIN_MESSAGE to leave and go back in my ProcessEvent to play next media

          pluginMessageCmd["EventType"] = "SEND_PLUGIN_MESSAGE"
          pluginMessageCmd["PluginMessage"] = "next"

    like you said I used the roList with the "push", "next", ... it's great, I now have some bugs to fix and optimization to do to make everything perfect

     

  • 0
    Avatar
    Bright Scripters

    Sorry about the ofcode link. I was not familiar with how it works.

     

    Just in case you'd like to look at the code I put there. I've added a timer which handles the images duration, without blocking BrightScript, and by that avoid reboot.

    https://paste.ofcode.org/EDxMPxaSfmTLTYZFG8bQNK

    The code is for guidance only, and probably requires tweaking.

     

    Function USBPlayer_Initialize(msgPort As Object, userVariables As Object, bsp as Object)
        print "USBPlayer_Initialize - Start"
    	USBPlayer = newUSBPlayer(msgPort, userVariables, bsp)
    	return USBPlayer
    End Function
    
    Function newUSBPlayer(msgPort As Object, userVariables As Object, bsp as Object)
    	print "newUSBPlayer"
        p = {}
        p.version = 1.0
        p.msgPort = msgPort
        p.userVariables = userVariables
    	p.bsp = bsp
    	p.debug  = false
        p.objectName = "USBPlayer_object"
        p.ProcessEvent = USBPlayer_ProcessEvent
        
        p.MyUSBPlayer = MyUSBPlayer 
        p.GetNextMedia = GetNextMedia
        p.PlayMedia = PlayMedia
            
        PictureDelay% = userVariables.Lookup("PictureDelay").GetCurrentValue().toint()
        MaxUSBLoop%   = userVariables.Lookup("MaxUSBLoop").GetCurrentValue().toint()
       
        p.ImageTimer = CreateObject("roTimer")
        p.ImageTimer.SetElapse(PictureDelay%,0)
        p.ImageTimer.SetPort(msgPort)
        p.ImageTimer.SetUserData(box("ImageTimer"))
              
        p.v=CreateObject("roVideoPlayer")  
        p.v.SetPort(p.msgPort)
        
        p.MediaList = ListDir("USB1:") 
        p.MediaList.Reset()
            
        p.PlayMedia() 
        
       
        return p
    End Function
     
    Function USBPlayer_ProcessEvent(event As Object) as boolean
    	print "USBPlayer process event"
        
        if ( type(event)= "roVideoEvent" and event.GetInt() = 8  ) or ( type(event)= "roTimerEvent" and event.GetUserData() = "ImageTimer" ) then
        
            MediaFileName$ = m.GetNextMedia()
            print "About to play file: "; MediaFileName$
            m.PlayMedia( MediaFileName$ )      
        
        else if type(event) = "roAssociativeArray" then
            
            if type(event["EventType"]) = "roString" then
              if event["EventType"] = "SEND_PLUGIN_MESSAGE" then
                if event["PluginName"] = "USBPlayer" then
        					
                            if LCase(event["PluginMessage"]) = "play" then
    
         
                                  pluginMessageCmd = CreateObject("roAssociativeArray")
                                  pluginMessageCmd["EventType"] = "EVENT_PLUGIN_MESSAGE"
                                  pluginMessageCmd["PluginName"] = "USBPlayer"
                                  pluginMessageCmd["PluginMessage"] = "end"
                                  m.msgPort.PostMessage(pluginMessageCmd)
                                  sleep(1000) ' Why the delay?
                                  return true
                                  
        					end if
                            
                endif
              endif
            endif
        else
    		return False
        endif
    End Function
    
    
    function IsImage(MediaFileName$) as boolean
    
        FileExt$ = lcase(MediaFileName$.Right(4))
        
            if FileExt$ = ".jpg" or FileExt$ = ".png" then return true
        
        return false
    
    end function
    
    
    function GetNextMedia()
    
            if m.MediaList.IsNext() then m.MediaList.Reset()
        
        return m.MediaList.Next()
    
    end function
    
    
    sub PlayMedia( MediaFileName$ )
        
            if IsImage(MediaFileName$) then
                m.v.PlayStaticImage(MediaFileName$)
                m.ImageTimer.Start() 
            else
                m.v.PlayFile(MediaFileName$)
            end if
            
    end sub

     

  • 0
    Avatar
    Greg

    Great "TimerEvent"! I'm going to use it.

    Small question with the "newUSBPlayer" function is it called at each "ProcessEvent" or just once ? because I must be able to change my usb key without having to reboot the brightsign.

    for "sleep(1000) ' Why the delay?" it's certainly an oversight from an old test ^^

    Thank you for your code I will use it to optimize and finalize mine :) and thank you for the help I'm really starting in Brightscripting you really help me well ! ^^

  • 0
    Avatar
    Bright Scripters

    newUSBPlayer is called once.

     

    There might be an event generated when USB drive is ejected/inserted, that you could listen to, but I'm not sure.

    You could watch the serial terminal or ssh as you remove the USB drive, and see if anything gets printed by

    print "USBPlayer process event"

    You can find what event that is like so:

    print "USBPlayer process event "; type(event)


  • 0
    Avatar
    Greg

    Thanks :


    USBPlayer process event roStorageDetached
    USBPlayer process event roStorageAttached

     

    I have finish my player every think is working thanks a lot :)

  • 0
    Avatar
    Bright Scripters

    You are a rock star! Nicely done!

    Glad to have been able to help.

     

  • 0
    Avatar
    Greg

    Hello, I'm back! lol
    I have added some functionality on my code and I encounter 1 small problems ^^ yes again ...

    Can we display images or video over BrightAuthor presentations?
    => I have added AutoPlay to the USB stick connection but the media is displayed in the background

    Thank you again and again

  • 0
    Avatar
    Bright Scripters

    Welcome back!

     

    Please share picture showing the result.

    Please describe what you are trying to accomplish. Somewhat unclear...

     

    Few questions:

    What text editor are you using?

    How do you transfer an updated plugin from the editor to the SD card?

    Do you reboot the player every time you update the plugin?

    Do you have access to the brightscript debugger through ssh or serial terminal?

  • 0
    Avatar
    Greg

    Hello, the result is simple, i see only my presentation lol.

    I use "roStorageAttached" event, to start my script for displaying picture or video with an "roVideoPlayer" over than my BrightAuthor presentation but if i dont change anything on my BrightAuthor presentation the "roVideoPlayer" turn in background, i "see" it with an SSH login but nothing on screen ...

    actualy i'm cheating with using an transparant png on brightauthor but i want to be able to display without change anything on my presentation.

    my text editor is Notepad++, i send all my update with Brightauthor that rebooting my brightsign every time and yes i'm using SSH but only to display my "Print" and show my error when red light is blingking ^^

    Sorry if my english is not so good this time i dont have used DeepL translator :P

    Thanks

  • 0
    Avatar
    Bright Scripters

    Would be easier if you posted your files, so we can examine closer.

    Playback depends on the particular player model that you are using, and whether you are playing media at full screen or not.

  • 0
    Avatar
    Greg

    Hello are you the same person than help me before ? my script is same as before juste corected and updated ... i have not acess right now to my project folder but i can make an quick sample :

    https://paste.ofcode.org/32ZDGn34rwcDUTVrGchULR6

    Simply when an storage is atached i want to display all media inside this, all the part of listing and playing is working fine but i always have to notifying my BrightSign Presentation to change to an transparent png. without that impossible to see my media on screen.

    Thanks

  • 0
    Avatar
    Bright Scripters

    This time I'm more interested in the presentation file, and which model you are working with.

     

  • 0
    Avatar
    Greg

    Hello, the player is an LS424 for now (for my test, can be an other with USB port) and my presentation is :

     

    Thanks :)

  • 0
    Avatar
    Bright Scripters

    That helps.

     

    Is the zone your are showing of type VideoOrImages, or is it of type images?

    Possibly, the player is not capable of showing a video, and an overlaid image at once.

    You could try replacing Transparent_PNG.png, with an Event Handler, and check "Stop Playback". That would remove the Wait.png image from the screen.

    Alternatively, you could create the on-screen prompts from BrightScript, through use of

    https://docs.brightsign.biz/display/DOC/roTextWidget

    or

    https://docs.brightsign.biz/display/DOC/roTextField

    That would eliminate the need for the BrightAuthor states and events.

Please sign in to leave a comment.