0

Calling ParseGPSdataGPRMCformat() to load a user variable

Ultimately am trying to get GPS data into an HTML5 web page call to give the web page a locus on which to work. (The web page pulls up a map.)

The GPS dongle that I am using speaks at 9600 baud so I cannot check it as a GPS Receiver under interactive. That being said, I have just set it up on the serial 2 port and am capturing the GPS serial string when it comes into the player on that port and shoving it into a user variable named CurrentGPDData. This works.

For developing this a bit at a time, the next step is to get the lat lon and valid properties available to the system. I am attempting to set user variable PosLat to ParseGPSdataGPRMCformat($$CurrentGPSData$$).latitude.   This passes the correct serial string into the function but PosLat just becomes that call string instead of the function return. 
This is what ends up in PosLat:

Obviously, I am doing this wrong somehow.

Any ideas how I can call ParseGPSdataGPRMCformat() and get the data extracted for use?

The function is already in the autorun.brs. I really wouldn't want to re-invent the wheel.

Thanks..

David

 

 

10 comments

  • 0
    Avatar
    Bright Scripters

    I think you would need to use a BA plugin for that.

    You would listen to serial events in order to capture the information, then parse it to get the location info, and place it in your variable.

    The variable could then be used in your HTML URL. Something like:

    http://mymap.me/showmap?$$GPSinfo$$

    Have not done it before, so start my manually assigning the GPS info that would be parsed into a variable, and set the HTML URL as shown above.

    If that works, you would then need to figure out the plugin.

  • 0
    Avatar
    David Herde

     I have been pussyfooting around plugins, but I am a little overwhelmed at all the stuff in the 'BLANK Plugin' available in the plugins area. Way too much stuff that I don't understand. So. I was trying to be a little more direct. Is there a way to call a .brs function from an event command?

  • 0
    Avatar
    Bright Scripters

    There is non to my knowledge.

    Coding Plugins has a steep learning curve, but once you get the hang of it, is very rewarding, as it makes almost anything possible.

     

     

  • 0
    Avatar
    Bright Scripters

    Can you post a sample of what the GPS is sending down the serial port? 

    Is it sending a line of text with CR or such?

  • 0
    Avatar
    David Herde

    If you look in the picture posted, You can see what the GPS is returning inside the parenthesis of the function that I am trying to call. It starts with the $GPGLL.......

    In a setvariable field can you put equations and functions? In the autorun.brs, ParseGPSdataGPRMCformat() is actually a subroutine and not a function. It creates an object (interface whatever..)

    Can I make a simple plugin that just calls the ParseGPSdataGPRMCformat() subroutine and sets the user variables? Do I need all that other stuff that is in the plugin template?

     

  • 0
    Avatar
    David Herde

    I created a plugin tarcplugin.brs and included it into the presentation.(contents below)

    The plugin just contains some modified code pulled from the autorun.brs  which enables the geofencing functionality.

    I have a single function in there. I am  not sure if the m.bsp object references will still work or not. (I may have to strip them out, but they are useful if they work.

    (more below)

    ****************************************************************************************************************************

    function LoadGPSVars(gpgllstring, fxactv, lat, lon) as boolean
    ' This fuction will receive a GPGLL string , parse it, load the variables and return true if successful
    ' It requires that the autorun.brs contain the ParseGPSdataGPRMCformat subroutine.

        LoadGPSVars = False
        gpsData = ParseGPSdataGPRMCformat(gpgllstring)
        
            if gpsData.valid then

                logGPSEvent = false            
                ' log GPS events on first event, then no more frequently than every 30 seconds
                currentTime = m.bsp.systemTime.GetLocalDateTime()
                if type(m.nextTimeToLogGPSEvent$) = "roString" then
                    if currentTime.GetString() > m.nextTimeToLogGPSEvent$ then
                        logGPSEvent = true
                    endif
                else
                    logGPSEvent = true
                endif

                if logGPSEvent then
                    currentTime.AddSeconds(30)
                    m.nextTimeToLogGPSEvent$ = currentTime.GetString()
                endif

                if gpsData.fixActive then

                    if logGPSEvent then
                        m.bsp.logging.WriteDiagnosticLogEntry(m.bsp.diagnosticCodes.EVENT_GPS_LOCATION, str(gpsData.latitude) + ":" + str(gpsData.longitude))
                    endif

                    m.bsp.diagnostics.PrintDebug("GPS location: " + str(gpsData.latitude) + "," + str(gpsData.longitude))
                    m.bsp.gpsLocation.latitude = gpsData.latitude
                    m.bsp.gpsLocation.longitude = gpsData.longitude

                    'latitudeInRadians = ConvertDecimalDegtoRad(m.bsp.gpsLocation.latitude)
                    'longitudeInRadians = ConvertDecimalDegtoRad(m.bsp.gpsLocation.longitude)
                    'uservariable.setcurrentvalue(string, true)
                    fxactv.setcurrentvalue(gpsData.fixActive, true)
                    lat.setcurrentvalue(gpsData.latitude, true)
                    lon.setcurrentvalue(gpsData.longitude, true)
                    LoadGPSVars = True
                else
                    if logGPSEvent then
                        m.bsp.logging.WriteDiagnosticLogEntry(m.bsp.diagnosticCodes.EVENT_GPS_NOT_LOCKED, "")
                    endif

                    m.bsp.gpsLocation.latitude = invalid
                    m.bsp.gpsLocation.longitude = invalid

            endif
            else
                ' print "GPS not valid"
            endif

    end function

     

    *****************************************************************************************************************************

     

    I am trying to call the function through the set variable function of the text field. I figure that if I can run the function from there, it should do everything and just return true. False elsewise. (Is true = 1 and false = 0 in this system?)

     

    What I end up getting appears to be the old artifacts from where I was setting the variables manually that stayed inside the flash for the user variables. I do not know if the LoadGPSVars() function code is even getting called to run.

    Am I on the right track? If not, where do I go?

    If I am on the right track, I would love any guidance. I am at a wall.

    Thanks..

     

  • 0
    Avatar
    David Herde

    How does one just call some code in a plugin to run?

  • 0
    Avatar
    Bright Scripters

    Could you use a terminal app to capture about a 1 minute worth of whatever your GPS is sending.

    I have some code that I'd like to see if it can successfully parse your data.

    If you'd like, you could email the captured data to info@brightscripters.com 

  • 0
    Avatar
    David Herde

    I have sent what the GPS is sending.

    I can capture the correct $$GPGLL statement but cannot find a way to call the Parsing function that already exists inside the autorun.

    I am new to scripting and have not been able to figure out how to get a script to  work. Since I cannot call the existing parsing function I have been trying to put it in a plugin which I haven't been able to figure out yet. Reinventing the wheel is not my preferred method, but I am not getting so far there either..

     

    Learning curve…

    It would be nice if there was a video showing the parts needed to write a plugin and where and how you get them into your project and how you set up the proper messages  to initialize and call the functions.

    Thanks for any help

  • 0
    Avatar
    David Herde

    Is there by chance any way to query the gpsdata object properties directly from a user developed plugin?

Please sign in to leave a comment.