8 Replies Latest reply on Apr 20, 2016 8:02 PM by Iosif

    Grove GPS Python script not running on Edison

    Vrukesh

      Hi All,


      We are using Intel Edison board and have Grove GPS module SIM28. We are trying to use Python script at: IoT - Grove GPS | Intel® Developer Zone

       

      We get following errors which stop Python script from executing:

      1. AttributeError: Unknown C global variable 'int_B9600'

      This corresponds to line 23 in script:

      if (not myGPSSensor.setupTty(upmUblox6.cvar.int_B9600)):

       

      2. AttributeError: 'module' object has no attribute 'charArray'

      This corresponds to line 23 in script:

      nmeaBuffer = upmUblox6.charArray(bufferLength)

       

      Would appreciate any help to resolve these errors. Please feel free to let me know if you need any more information.

      Thanks and Regards,

      Vrukesh

        • 1. Re: Grove GPS Python script not running on Edison
          DiegoV_Intel

          Hello Vrukesh,

           

          I checked the script and ran it. I got the same errors as you. According to the errors, the upmUblox6 object doesn't have the attribute "charArray", and the variable "int_B9600" is not specified anywhere. I checked the source code (upm/src/ublox6 at master · intel-iot-devkit/upm · GitHub) and I confirmed it. That is why there are errors when you attempt to run the code.

           

          I would suggest you to try running the C++ example instead, but if you prefer to keep using the Python example, you could try to do some fixes in the example code. I haven't tested it with the GPS module because I don't have it, but I was able to run the Python code with the following modifications:

           

          1. The first error is because the variable "int_B9600" is not defined. The method that required this variable is myGPSSensor.setupTty(upmUblox6.cvar.int_B9600). This method is used to set the baudrate of the serial port. According to the source code, the default value is 9600 so you can call the method with no arguments and by default the serial port should be initialized with a baudrate of 9600.
          2. The second error is because the attribute "charArray" is not defined. If you look what that line does, you will notice that it is used to set a buffer of size 256 to store the data read. I replaced that line by this one: nmeaBuffer = []. It doesn't throw any error but I'm not sure if it is going to work with that.

           

          If you do those modifications and try to run the code again, there are not going to be errors, but I don't know if it will work. You can try it and test it with your GPS module. If it doesn't work, my suggestion would be to try with the C++ example version.

           

          Regards,

          Diego.

          • 2. Re: Grove GPS Python script not running on Edison
            Vrukesh

            Hi Diego,

             

            Python script: Tried to implement the suggested changes.

            #1 change of empty function worked fine.

            #2 of charArray works fine, but throws error at line 42: rv = myGPSSensor.readData(nmeaBuffer, bufferLength)
            So, Python script does not execute.

             

            C++ Example code: It also does not compile. Throws error messages as follows:

            line 95: undefined reference to `upm::Ublox6::~Ublox6()'

            line 73: undefined reference to `upm::Ublox6::dataAvailable()'

            line 75: undefined reference to `upm::Ublox6::readData(char*, unsigned int)'

            line 51: undefined reference to `upm::Ublox6::setupTty(unsigned int)'

            line 48: undefined reference to `upm::Ublox6::Ublox6(int)'

             

            Any suggestions ?

             

            Thanks and Regards,

            Vrukesh

            • 3. Re: Grove GPS Python script not running on Edison
              DiegoV_Intel

              Hello Vrukesh,

               

              I've answered you through the ticket you sent. Please check my suggestions there, and in case you still have errors post them back here.

               

              Regards,

              Diego.

              • 4. Re: Grove GPS Python script not running on Edison
                ZionICS

                Thank you Diego for all your work on this issue. And thank you Vrukesh for bringing this issue up to us!

                 

                This module was definitely tested with python.

                 

                Unfortunately it appears that one of the files used to build the python module (upm/pyupm_ublox6.i at master · intel-iot-devkit/upm · GitHub) is old.

                 

                Updating it will probably fix this issue in future versions of upm. We're working on this.

                 

                In the meantime, using the workarounds above or using either the C++ or JavaScript examples might allow you to run the GPS sensor.

                 

                My apologies, and thank you again!

                 

                Take care,

                Zion

                • 5. Re: Grove GPS Python script not running on Edison
                  robot_

                  I am having the same issue.  Is there any fix for getting gps data off of this sensor using the edison?

                  • 6. Re: Grove GPS Python script not running on Edison
                    robot_

                    This is a temporary solution:

                     

                    import mraa
                    
                    
                    u = mraa.Uart(0)
                    u.setBaudRate(9600)
                    print u.getDevicePath()
                    
                    
                    while (True):
                      if(u.dataAvailable()):
                           buff = u.readStr(256)
                      if buff.find("GPGGA") != -1: #this is the easiest to parse
                           smallerbuff = buff[buff.find("GPGGA"): buff.find("\n")]
                           splitbuff = smallerbuff.strip().split(",")
                           #print(splitbuff)
                           latnmea = splitbuff[2]
                           latdir = splitbuff[3]
                           lonnmea = splitbuff[4]
                           londir = splitbuff[5]
                           lat = float(latnmea[0:2]) + float(latnmea[2:])/60
                           lon = float(lonnmea[0:3]) + float(lonnmea[3:])/60
                           if londir == "W":
                                lon = lon * -1
                           alt = float(splitbuff[9])
                      #does lat need similar work done to it
                      #how do i switch of unused sentences?
                      print("%f,%f") % (lat,lon)
                      print("%f M") % alt@@
                    
                    
                    
                    
                    
                    
                    
                    

                     

                    @Vrukesh

                     

                    • 7. Re: Grove GPS Python script not running on Edison
                      ZionICS

                      I like this workaround!

                       

                      The new pyupm_ublox6.i file was merged on August 20.

                       

                      If you have updated mraa/upm source after August 20, you should be able to use the python example with a ublox6 GPS module.

                       

                      upm/ublox6.py at master · intel-iot-devkit/upm · GitHub

                       

                      Thanks,

                      Zion

                      • 8. Re: Grove GPS Python script not running on Edison
                        Iosif

                        I have the same problem in C++ using VisualGDB. Any fix on this?

                         

                        Thank You!