Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Get positionSource with GPS receiver and serial port com

Get positionSource with GPS receiver and serial port com

Scheduled Pinned Locked Moved Solved General and Desktop
positionsourcelocationgpspositioningserial port
13 Posts 5 Posters 8.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lulu31
    wrote on 9 May 2016, 09:27 last edited by
    #1

    Hello
    I am using a positionSource in QML project.
    It works in simulation mode when i put the positionSource.nmeasource = "nmealog.txt" but how to put in real mode and receive position from a gps connected by serial port ?

    Thank you for your help

    ? F 2 Replies Last reply 9 May 2016, 10:54
    1
    • L Lulu31
      9 May 2016, 09:27

      Hello
      I am using a positionSource in QML project.
      It works in simulation mode when i put the positionSource.nmeasource = "nmealog.txt" but how to put in real mode and receive position from a gps connected by serial port ?

      Thank you for your help

      ? Offline
      ? Offline
      A Former User
      wrote on 9 May 2016, 10:54 last edited by A Former User 5 Sept 2016, 10:55
      #2

      Hi! First check if there is a backend plugin available for your GPS receiver: [static] QStringList QGeoPositionInfoSource::availableSources()

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Lulu31
        wrote on 10 May 2016, 06:03 last edited by
        #3

        Hi !

        I did what you asked and I have one available source plugin which is named geoclue.
        How to know if it is the one corresponding to my device ?

        If it is the one, what to do next ?
        Because my code is only in QML, so I have to add C++ files to keep back position from device and send a signal to QML file where there is the positionSource ?

        ? 1 Reply Last reply 10 May 2016, 06:09
        0
        • L Lulu31
          10 May 2016, 06:03

          Hi !

          I did what you asked and I have one available source plugin which is named geoclue.
          How to know if it is the one corresponding to my device ?

          If it is the one, what to do next ?
          Because my code is only in QML, so I have to add C++ files to keep back position from device and send a signal to QML file where there is the positionSource ?

          ? Offline
          ? Offline
          A Former User
          wrote on 10 May 2016, 06:09 last edited by
          #4

          @Lulu31 said:

          so I have to add C++ files to keep back position from device and send a signal to QML file where there is the positionSource ?

          No. I just wanted to make sure that there is a plugin for your device. You can use the plugin like this:

           PositionSource {
                id: src
                name: "geoclue"
                updateInterval: 1000
                active: true
          
                onPositionChanged: {
                    var coord = src.position.coordinate;
                    console.log("Coordinate:", coord.longitude, coord.latitude);
                }
            }
          
          L 1 Reply Last reply 10 May 2016, 06:18
          0
          • ? A Former User
            10 May 2016, 06:09

            @Lulu31 said:

            so I have to add C++ files to keep back position from device and send a signal to QML file where there is the positionSource ?

            No. I just wanted to make sure that there is a plugin for your device. You can use the plugin like this:

             PositionSource {
                  id: src
                  name: "geoclue"
                  updateInterval: 1000
                  active: true
            
                  onPositionChanged: {
                      var coord = src.position.coordinate;
                      console.log("Coordinate:", coord.longitude, coord.latitude);
                  }
              }
            
            L Offline
            L Offline
            Lulu31
            wrote on 10 May 2016, 06:18 last edited by
            #5

            @Wieland Ok I tried but I never receive a position and so never receive the PositionChanged signal ...
            How do you know that geoclue is the plugin for my external device ? Because we can have the gps position with internet too ...

            ? 1 Reply Last reply 10 May 2016, 06:23
            0
            • L Lulu31
              10 May 2016, 06:18

              @Wieland Ok I tried but I never receive a position and so never receive the PositionChanged signal ...
              How do you know that geoclue is the plugin for my external device ? Because we can have the gps position with internet too ...

              ? Offline
              ? Offline
              A Former User
              wrote on 10 May 2016, 06:23 last edited by
              #6

              @Lulu31 Oh. Looks like "geoclue" is this: https://www.freedesktop.org/wiki/Software/GeoClue/ :-/

              1 Reply Last reply
              0
              • L Offline
                L Offline
                Lulu31
                wrote on 10 May 2016, 06:42 last edited by
                #7

                Thank you !

                I am not sure this is the thing that I need.

                I can receive my gps position inside terminal using the following command : sudo stty -F /dev/ttyUSB0 ispeed 4800 && cat < /dev/ttyUSB0.

                So I will try to read from QT directly.

                Perhaps, there is a class in QT to do that ?

                Anyway, I will search.

                ? 1 Reply Last reply 10 May 2016, 06:48
                0
                • L Lulu31
                  10 May 2016, 06:42

                  Thank you !

                  I am not sure this is the thing that I need.

                  I can receive my gps position inside terminal using the following command : sudo stty -F /dev/ttyUSB0 ispeed 4800 && cat < /dev/ttyUSB0.

                  So I will try to read from QT directly.

                  Perhaps, there is a class in QT to do that ?

                  Anyway, I will search.

                  ? Offline
                  ? Offline
                  A Former User
                  wrote on 10 May 2016, 06:48 last edited by
                  #8

                  Okay, unfortunately the nmeaSource property of QML PositionSource only support simulation mode. So you'll need some C++ stuff to use your device. Take a look at this: QNmeaPositionInfoSource. If you create your own class, derived from QNmeaPositionInfoSource, and make this available to your QtQuick environment then things should work. Another possibility would be to follow the Log File Position Source (C++) example and subclass QGeoPositionInfoSource to create a custom positioning source for your device.

                  1 Reply Last reply
                  1
                  • L Offline
                    L Offline
                    Lulu31
                    wrote on 11 May 2016, 05:39 last edited by
                    #9

                    Finally, I used the log File Position Source example and it works. Thank you !

                    ? 1 Reply Last reply 11 May 2016, 05:42
                    0
                    • L Lulu31
                      11 May 2016, 05:39

                      Finally, I used the log File Position Source example and it works. Thank you !

                      ? Offline
                      ? Offline
                      A Former User
                      wrote on 11 May 2016, 05:42 last edited by
                      #10

                      @Lulu31 Great! :-)

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        guicc
                        wrote on 20 May 2016, 14:49 last edited by guicc
                        #11

                        OP, could you explain how you integrated the QGeoPositionInfoSource code into your QML code?

                        I have created a plugin using QGeoPositionInfoSourceFactory that returns my subclass from QGeoPositionInfoSource.
                        Then I have created a qmldir file like so:

                        module MyPositionModule
                        plugin MyPositionPlugin
                        

                        And tried:

                        positionSource: PositionSource {
                                id: positionSrc
                                updateInterval: 100 //ms
                                name: "MyPositionPlugin"
                        
                                onPositionChanged: {
                                       console.log(positionSrc.position.coordinate.latitude, " ", positionSrc.position.coordinate.longitude);
                                 }
                        

                        When I call positionSrc.start() the sourceError property does not change (NoError). But I do not receive updates and positionSrc.supportedPositioningMethods prints garbage.

                        P.S.: My plugin metadata is in the json:

                        {
                            "Keys": ["MyPositionPlugin"],
                            "Provider": "Me",
                            "Position": true,
                            "Satellite": false,
                            "Monitor": false,
                            "Priority": 1000,
                            "Testable": true
                        }
                        
                        1 Reply Last reply
                        1
                        • L Lulu31
                          9 May 2016, 09:27

                          Hello
                          I am using a positionSource in QML project.
                          It works in simulation mode when i put the positionSource.nmeasource = "nmealog.txt" but how to put in real mode and receive position from a gps connected by serial port ?

                          Thank you for your help

                          F Offline
                          F Offline
                          Frank84
                          wrote on 13 Aug 2016, 19:01 last edited by Frank84
                          #12

                          @Lulu31 "I am using a positionSource in QML project.
                          It works in simulation mode when i put the positionSource.nmeasource = "nmealog.txt" "

                          Hi ¿Lulu could you share this project with the nmealog.txt log file please?, i'm trying this but no success so far. Thank you

                          1 Reply Last reply
                          2
                          • ArasA Offline
                            ArasA Offline
                            Aras
                            wrote on 31 Aug 2016, 22:28 last edited by
                            #13

                            I am also trying to write a minimal qml app that uses the built in GPS to retrieve current position. I am not sure if I can use Qt positioning or if I should just parse the raw output of the GPS myself, like the OP did here, and extract the position manually. It seems very dirty to do it that way, I thought there would be a nice API in QML that I could use. Anyone can point to a simple example?

                            1 Reply Last reply
                            2

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved