0

brightsign script plugin

I need my custom script plugin to run. I added to the presentation properties. I added as a Timeout and media end events but it looks like its not running. The plugin gets some info from the device and POST to some REST end point. 

Here is the Script:

Function deviceInfo_Initialize(msgPort As Object, userVariables As Object, bsp as Object)

deviceInfo= {}
deviceInfo.msgPort = msgPort
deviceInfo.userVariables = userVariables
deviceInfo.bsp = bsp
deviceInfo.ProcessEvent=deviceInfo_ProcessEvent

deviceInfo.name = "deviceInfo"
deviceInfo.version = 0.1

' --------------- Get the Serial Number of the Unit
player=CreateObject("roDeviceInfo")
deviceInfo.uniqueId = player.GetDeviceUniqueId()

' --------------- Get the Name of the Unit
registrySection=CreateObject("roRegistrySection", "networking")
deviceInfo.unitName = registrySection.Read("un")

' --------------- Get the IP Address of the Unit
net=CreateObject("roNetworkConfiguration", 0)
ifnet= invalidthen
net=CreateObject("roNetworkConfiguration", 1)
    endif

deviceInfo.ip = ""

ifnet<> invalidthen
deviceInfo.ip = net.GetCurrentConfig().ip4_address
    endif

' --------------- Get the Channel Url
currentSync=CreateObject("roSyncSpec")
deviceInfo.channelUrl = ""

ifnot currentSync.ReadFromFile("current-sync.xml") then
     print "### No current sync state available"
else
deviceInfo.channelUrl = currentSync.LookupMetadata("client", "base")
    endif


return deviceInfo
End Function



Function deviceInfo_ProcessEvent(event as Object) as boolean
    retval = false
print "Type of event is ";type(event)
 
    if type(event) = "roAssociativeArray" then
iftype(event["EventType"]) ="roString"
if (event["EventType"] ="SEND_PLUGIN_MESSAGE") then
if event["PluginName"] ="DeviceInfo"then
print "event DeviceInfo"
pluginMessage$ = event["PluginMessage"]
retval=SendDeviceInfo(pluginMessage$, m)
endif
endif
endif
    endif

    if type(event) = "roDatagramEvent" then
     msg$ = event
     retval = SendDeviceInfo(msg, m)
    end if
    return retval
end Function

17 comments

  • 0
    Avatar
    Lyndon

    can you post a link to the actual plugin as it's hard to tell if some of the spacing in your post is formatting or if you have spaces missing in the plugin itself. 

     

    Also, what do you mean it's not running? Is there an error in the system  log that says the plugin is invalid? If so, it should report an error code from the eva() call, in the system log.

    Or did the plugin load, but some part of it isn't working?

     

    What exactly is it supposed to do, and where in that process is it falling down?

     

  • 0
    Avatar
    Bright Scripters

    Can you provide a download link to the plugin file, and the BrightAuthor project?

    There is a call to a function SendDeviceInfo() which I'm not seeing defined in the code.

     

  • 0
    Avatar
    Sabin Maharjan

    https://github.com/sabmah/BrightSign/blob/master/deviceInfoPlugin.brs

    I wanted to run this in a timer so that it can send device info to the service endpoint. I don't see such 'timer' events and so I added it to the timeout event or media end event. Both of them didn't seem to work because I don't see any logs of it running on diagnostic web server.

  • 0
    Avatar
    ^UD\_$

    Which player model are you using?

    What firmware?

    What version of BrightAuthor?

    How do you publish?

    Are you on the BrightSign Network?

  • 0
    Avatar
    Sabin Maharjan

    MODEL: XT1143

    FIRMWARE: 6.2.94

    BRIGHTAUTHOR VERSION: 4.6.0.18

    PUBLISH: SIMPLE FILE NETTWORK

    NOT ON BRIGHTSIGN NETWORK!

  • 0
    Avatar
    Lyndon

     

     

    One problem with your script is the senddeviceinfo function. You pass in the m object as h. But, in the function, you referecen deviceinfo.ip, deviceinfo.channelurl, etc..

    Instead of using deviceinfo.xyz, you need to use h.ip, h.channelurl, etc..

    H is what refers back to the deviceinfo object you created, and passed into the senddevice info function.  All "deviceinfo." should be replaced by "h.".

     

       
  • 0
    Avatar
    Sabin Maharjan

    I changed into "h." like you said but still no dice. Here are my States.

     

     




  • 0
    Avatar
    ^UD\_$

    Have you defined a User Variable with name DeviceInfo_url?

    Are you watching the serial port output, so you can capture a message such as the one below?

    print "No DeviceInfo_url user variable is defined."

  • 0
    Avatar
    Sabin Maharjan

    No. I don't see that my plugin is fired. I don't see any of my print messages.

  • 0
    Avatar
    Lyndon

     

    where are you looking for them? Print statements show up in telnet connections or if you have a serial cable connected to your player, assuming it has serial port.

    If you're looking in the system log, then a generic print doesn't show up in the system log.  You can use the printdebug call inside a plugin with any function that's attached to the main plugin object...

    m.bsp.diagnostics.printdebug("Put your string here")

    This sends output to serial and the system log.  So, in the function where you create the deviceinfo object, you would reference this using deviceinfo.bsp.diagnostics.printdebug().

     

    And, in the function where you passed in the main object, you would call h.bsp.diagnostics.printdebug().

     

     

     

  • 0
    Avatar
    ^UD\_$

    Working on a plugin without a serial terminal, is almost as effective as riding the bicycle blindfolded :)

     

  • 0
    Avatar
    Bright Scripters

    Put differently, you'd benefit from connecting your development player to a computer, running a terminal application such as Putty.

    You would need a serial port on both the player, and the PC, and a serial cable to connect between them.

    Baud Rate is normally 115200

  • 0
    Avatar
    Sabin Maharjan

    I don't have any serial connections. Can I put this in script in my plugin and start telnet? or ssh?

     

    reg = CreateObject("roRegistrySection", "networking")
    reg.write("telnet","23")
     
    reg = CreateObject("roRegistrySection", "networking")
    reg.write("ssh","22")
      
    n=CreateObject("roNetworkConfiguration", 0)
      
    n.SetLoginPassword("password")
    n.Apply()
  • 0
    Avatar
    Lyndon

    Sorry if I wasn't clear. You can access the system log by logging into the player's ip address, and going to the log tab. The default password, unless you set it to something different, is the serial # of the unit.

     

    Once in the system log you'll see output from the printdebug statements I mentioned earlier.

     

    Yes, could add this code to your plugin:

     

    reg = CreateObject("roRegistrySection", "networking")
    reg.write("telnet","23")
     
    It would be active after a reboot, and you could then telnet to that port on the player. 
  • 0
    Avatar
    Bright Scripters

    You may want to put the player in debug mode, so you get access to the debugger when needed.

    Here is how:

    Once you have telnet or ssh connection, press the svc button, which should exit the script to the BrightSign> shell.

    In the shell, type: script debug on

    To confirm that it took, type: script debug

    Confirm that debug is on, and reboot.

    Once the player is running again, re-connect with telnet or ssh.

    Hopefully I got this right :)

     

     

  • 0
    Avatar
    Sabin Maharjan

    Thanks for all the help guys. I have successfully compiled and ran the script. It now uploads device information periodically to my REST Endpoint.

    If anyone wants to check the code : https://github.com/PortOfPortland/BrightSign/blob/master/deviceInfoPlugin.brs

  • 0
    Avatar
    Bright Scripters

    Good job Sabin!

    Spoken like a true bright scripter!

    Please join our growing community by sending an email to Join@brightscripters.com 

Please sign in to leave a comment.