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.
  • Lulu31L Lulu31

    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 last edited by A Former User
    #2

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

    1 Reply Last reply
    0
    • Lulu31L Offline
      Lulu31L Offline
      Lulu31
      wrote on 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
      0
      • Lulu31L Lulu31

        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 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);
              }
          }
        
        Lulu31L 1 Reply Last reply
        0
        • ? A Former User

          @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);
                }
            }
          
          Lulu31L Offline
          Lulu31L Offline
          Lulu31
          wrote on 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
          0
          • Lulu31L Lulu31

            @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 last edited by
            #6

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

            1 Reply Last reply
            0
            • Lulu31L Offline
              Lulu31L Offline
              Lulu31
              wrote on 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
              0
              • Lulu31L Lulu31

                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 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
                • Lulu31L Offline
                  Lulu31L Offline
                  Lulu31
                  wrote on last edited by
                  #9

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

                  ? 1 Reply Last reply
                  0
                  • Lulu31L Lulu31

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

                    ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #10

                    @Lulu31 Great! :-)

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      guicc
                      wrote on 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
                      • Lulu31L Lulu31

                        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

                        Frank84F Offline
                        Frank84F Offline
                        Frank84
                        wrote on 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 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