Ntrip Client for AGOpenGPS - The Combine Forum
 84Likes
Reply
 
LinkBack Thread Tools
post #1 of 155 (permalink) Old 01-16-2019, 11:02 AM Thread Starter
Senior Member
 
Join Date: Nov 2016
Location: Austria
Posts: 733
Mentioned: 3 Post(s)
Quoted: 295 Post(s)
Ntrip Client for AGOpenGPS

Here is my ntrip client i have testet with agopengps.

Code:




//this i have at form.gps

            ntrip = new NTRIPtest(this);
            public NTRIPtest ntrip;

			
            ntrip.btnNTRIP_Click(); //starts the client


//NTRIPtest.cs  code starts here


 /* THIS CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
     INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
      PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
     OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE CODE
     OR THE USE OR OTHER DEALINGS IN THE CODE. */
    
   using System;
    using System.Net;
    using System.Net.Sockets;
    using System.Text;
    using System.Threading;
     
   namespace AgOpenGPS
{
        /// <summary>
        /// This is a simple example of how to request a NTRIP RTCM stream using C# Compact Framework,
        /// and pass it to the GPS using iter.dk's PocketGpsLib (demo available from http://www.iter.dk)
        /// Visit http://igs.ifag.de/index_ntrip.htm for more info on NTRIP
        ///    
        /// Note:
        ///     This is not a complete application. Some additional
        ///     programming is needed to implement into an application.
        ///     Furthermore this doesn't work with all GPS receivers. Your GPS receiver
      ///     must support DGPS via RTCM and this feature should be active.
      ///     Garmin eTrex is one of the receivers that supports this feature.
      ///     The eTrex should be set to RTCM/NMEA in SETUP -> INTERFACE -> I/O FORMAT (or similar)
        ///     This _should_ work with RTK receivers as well, but it haven't been tested. Let me know if it does.
     ///        
        /// Best result:
        ///     1.7m horisontal error during a 3 hour test (95% percentile)
        ///     Using Garmin eTrex, GPRS connection (SonyEricsson T68i) and iPAQ h3870.
        ///     Let me know of your testresults: http://www.iter.dk/contact.aspx
        ///
        /// 
        /// 
        /// (c) Morten Nielsen, 2004
        /// http://www.iter.dk
        /// v1.0
        /// </summary>
        public class NTRIPtest  //: System.Windows.Forms.Form
    {



        public string togps;
        public Socket sckt;
            //public static GPSHandler GPS;
            private System.Windows.Forms.Timer tmr;
            int BroadCasterPort;
            string username;
           string password;
            string stream;
            IPAddress BroadCasterIP;
        private readonly FormGPS mf;

        /// <summary>
        /// Initialize
        /// </summary>
        public NTRIPtest(FormGPS f)
              
         {
            mf = f;
            BroadCasterIP = IPAddress.Parse("xxxxxxx"); //Select correct Address
             BroadCasterPort = 2101; //Select correct port (usually 80 or 2101)
           stream = "MOUNT"; //Insert the correct stream
          username = "xxxxx"; //Insert your username!
             password = "xxxxx"; //Insert your password!

           // GPS = new GPSHandler(this); //Initialize GPS handler
           // GPS.NewGPSFix += new GPSHandler.NewGPSFixHandler(this.GPSEventHandler); //Hook up GPS data events to a handler
            this.tmr = new System.Windows.Forms.Timer();
            this.tmr.Interval = 100;
            this.tmr.Tick += new EventHandler(NTRIPtick);
        }

        /// <summary>
        /// Responds to sentence events from GPS receiver
        /// </summary>
        //  private void GPSEventHandler(object sender, GPSHandler.GPSEventArgs e)
        //  {
        //    if(e.TypeOfEvent==GPSEventType.GPGGA) //Global Positioning System Fix Data event
        //      if(GPS.GGA.FixQuality ==FixQualityEnum.DGPS) //We are running DGPS mode!
        //        {
        //             //The following info can be added to a status window
        //             //Seconds since last DGPS update: GPS.GGA.DGPSUpdate + " sec";
        //             //DGPS Station ID: GPS.GGA.DGPSStationID;
        //        }
        //}

        /// <summary>
        /// Fires when NTRIP start button is clicked
        /// </summary>
        public void btnNTRIP_Click()// (object sender, System.EventArgs e)
       {
             if(!tmr.Enabled) 
             {
                   StartNTRIP();
                  tmr.Enabled=true;
             }
             else
             {
                  tmr.Enabled=false;
                  StopNTRIP();
               }
           }
  
         /// <summary>
          /// Opens the connection to the NTRIP server and starts receiving
       /// </summary>
        public void StartNTRIP()
          {        
              //Connect to server
              sckt = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
              sckt.Blocking = true;
               sckt.Connect(new IPEndPoint(BroadCasterIP, BroadCasterPort));
   
             //Build request message
              string auth = ToBase64(username + ":" + password);
              string msg = "GET /" + stream + " HTTP/1.1\r\n";
             msg += "User-Agent: NTRIP iter.dk\r\n";
               msg += "Authorization: Basic " + auth + "\r\n"; //This line can be removed if no authorization is needed
            msg += "$GPGGA,141717.935,4827.720,N,01628.440,E,1,12,1.0,0.0,M,0.0,M,,*65" + "\r\n"; //this line can be removed if no position feedback is needed
              msg += "Accept: */*\r\nConnection: close\r\n";
            msg += "\r\n";
 
               //Send request
             byte[] data = System.Text.Encoding.ASCII.GetBytes(msg);
             sckt.Send(data);
            Console.WriteLine(msg);
              byte[] returndata = new byte[256];
    
             Thread.Sleep(100); //Wait for response
             sckt.Receive(returndata); //Get response
             string responseData = System.Text.Encoding.ASCII.GetString(returndata, 0, returndata.Length);
               ShowResponse(responseData);
            Console.WriteLine(responseData);
        }
   
         /// <summary>
        /// Stops receiving data from the NTRIP server
          /// </summary>
          private void StopNTRIP()
         {
            sckt.Shutdown(SocketShutdown.Both);
               sckt.Close();
          }
   
          /// <summary>
          /// Fired when timer ticks.
           /// Reads data from the NTRIP server and parses it to the GPS device.
           /// </summary>
           public void NTRIPtick(object o, EventArgs e)
           {
               byte[] returndata = new byte[256]; //clear buffer
               sckt.Receive(returndata);
               try 
               {

                if(mf.sp.IsOpen) 
                 {
                //    GPS.WriteToGPS(returndata); //Send RTCM data to GPS
               // string togps = System.Text.Encoding.UTF8.GetString(returndata);
                //mf.sp.WriteLine(togps);
                    mf.sp.Write(returndata, 0, returndata.Length);


                }
                

            }
           catch(System.Exception ex) 
               {
                   
                   tmr.Enabled=false;
                  // GPS.Stop();
                  sckt.Shutdown(SocketShutdown.Both);
                   sckt.Close();
                   throw(new System.Exception(("Error sending to GPS:" + ex.Message)));
               }
               string responseData = System.Text.Encoding.ASCII.GetString(returndata, 0, returndata.Length);
               ShowResponse(responseData);
            
            
        }
    
           /// <summary>
           /// Display responsedata for debugging use
           /// If the request is invalid (ie. invalid stream) a list of
           /// available streams will be returned instead.
           /// You should add code that handles any non-RTCM response. Refer to the NTRIP specification.
          /// </summary>
           /// <param name="strData"></param>
           private void ShowResponse(string strData)
          {
           }
           
           /// <summary>
           /// Apply AsciiEncoding to user name and password to obtain it as an array of bytes
           /// </summary>
           /// <param name="str">username:password</param>
           /// <returns>Base64 encoded username/password</returns>
           private string ToBase64(string str)
           {
               Encoding asciiEncoding = Encoding.ASCII;
               byte[] byteArray = new byte[asciiEncoding.GetByteCount(str)];
               byteArray = asciiEncoding.GetBytes(str);
               return Convert.ToBase64String(byteArray,0,byteArray.Length);
           }
       }
   }


BrianTee, WW, Kaupoi and 1 others like this.

Questions on agopengps? Just look into the wiki at
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
. Thanks to all contributors!

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Andreas Ortner is offline  
Sponsored Links
Advertisement
 
post #2 of 155 (permalink) Old 01-16-2019, 11:10 AM Thread Starter
Senior Member
 
Join Date: Nov 2016
Location: Austria
Posts: 733
Mentioned: 3 Post(s)
Quoted: 295 Post(s)
the code is from here:

https://www.sharpgis.net/post/2005/0...TCM-from-NTRIP


there are 2 different startup processes:

a) with vrs (Virtual Refernce Station) or NTRIP Server needs Positions Feedback
b) no position feedback is required


for a) the startup process is:

# start agopengps
# connect to gps device
# wait for a real position from gps
# ntrip.btnNTRIP_Click(); //starts the client (maybe that could be a button or automated service)
# the gga must be insert under: //Build request message
#some ntrip server needs the position only once, some ntrip server every x sec (minutes) - so that should be a parameter

for b)
client can be started at startup
the gga line could be removed from registration process
no position feedback


this data is needed:

BroadCasterIP = IPAddress.Parse("xxxxxxx"); //Select correct Address
BroadCasterPort = 2101; //Select correct port (usually 80 or 2101)
stream = "MOUNT"; //Insert the correct stream
username = "xxxxx"; //Insert your username!
password = "xxxxx"; //Insert your password!

at the moment code work as it is - but i think i needs some profi work
i think the eventhandler can be done with agopen not also inside the .cs

infos under:

http://www.wsrn3.org/CONTENT/Referen...Tech-paper.pdf

Marrek likes this.

Questions on agopengps? Just look into the wiki at
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
. Thanks to all contributors!

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by Andreas Ortner; 01-16-2019 at 11:26 AM.
Andreas Ortner is offline  
post #3 of 155 (permalink) Old 01-16-2019, 11:13 AM Thread Starter
Senior Member
 
Join Date: Nov 2016
Location: Austria
Posts: 733
Mentioned: 3 Post(s)
Quoted: 295 Post(s)
torriem, BrianTee, WTalen and 1 others like this.

Questions on agopengps? Just look into the wiki at
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
. Thanks to all contributors!

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Andreas Ortner is offline  
Sponsored Links
Advertisement
 
post #4 of 155 (permalink) Old 01-17-2019, 04:12 AM
Senior Member
 
Join Date: May 2018
Location: Serbia, Novi Sad
Posts: 143
Mentioned: 0 Post(s)
Quoted: 70 Post(s)
https://www.thecombineforum.com/foru...ml#post3308147

Quote:
Originally Posted by BrianTee View Post
Can you explain all the steps involved, fairly detailed, my knowledge of ntrip and corrections is embarrassingly limited. It seems like it shouldn't be terribly hard, but rarely turns out that way


Can a new thread be started?
NTRIP Client establishes TCP / IP communication with NTRIP caster.
In the first communication, NTRIP Client lists the Source table provided by the provider (MountPiont), but this does not have to be a rule, for example, there is a possibility to enter the known NTRIP Stream that the client can find out from the service provider or by entering the address and port in the Internet browser then our browser it drops the Source table list.
Or use a link
NTRIP Caster Table

So we see what suits us and write it directly to NTRIP Client, in addition to the other parameters assigned to us by the service provider: username, password, IP address and port.

I think it was very good that AGOpenGPS has an integrated NTRIP Client, which would establish a connection with the NTRIP caster and send corrections to the local network - broadcast to a specific port that the GNSS receiver would be tuned to, or to a serial port with certain baudrates.

Then the AOG could monitor the status of the NTRIP Client correction and we would not need another device, the most common phone, or use another application on your computer.
Of course, in this case, the computer would have to be connected to the Internet.

There is more about this here:

Networked Transport of RTCM via Internet Protocol
(Ntrip)
Attached Images
File Type: png ntrip.png (28.3 KB, 160 views)
File Type: png ntrip caster table.PNG (59.1 KB, 12 views)
p00qwerty likes this.

Last edited by ropecope; 01-17-2019 at 06:29 AM.
ropecope is offline  
post #5 of 155 (permalink) Old 01-17-2019, 12:29 PM
Senior Member
 
Join Date: Aug 2012
Location: Vermilion Alberta Canada
Posts: 5,426
Mentioned: 5 Post(s)
Quoted: 2372 Post(s)
It would all have to be written in asynch form, ie non blocking, like the udp server is.
BrianTee is offline  
post #6 of 155 (permalink) Old 01-17-2019, 01:08 PM
Senior Member
 
Join Date: Aug 2012
Location: Vermilion Alberta Canada
Posts: 5,426
Mentioned: 5 Post(s)
Quoted: 2372 Post(s)
I'm thinking that many of us don't have close by RTK bases, and moving a base around really has its disadvantages. So is the feeling that building an RTK base on your house etc for corrections and creating the RTCM corrections and sending them via internet to your tractor is kind of the goal here?


Can the UBlox M8P be sufficient for this task? Or just use the F9 for both.



Nice to have the whole project kind of in mind. it would seem this would be pretty ideal for most farms, all the tools i think are free, we just need to assemble.


Thoughts?
Kaupoi, alex lan and p00qwerty like this.
BrianTee is offline  
post #7 of 155 (permalink) Old 01-17-2019, 02:50 PM
Senior Member
 
Join Date: Sep 2009
Location: S. AB
Posts: 3,368
Mentioned: 5 Post(s)
Quoted: 828 Post(s)
Isn't the M8P only an L1 receiver? If your rover units are L1/L2, then they will work best with corrections that are also L1/L2. At least that's my understanding. So the F9P unit would make a good base station.
torriem is offline  
post #8 of 155 (permalink) Old 01-17-2019, 04:17 PM
Senior Member
 
Join Date: May 2018
Location: Serbia, Novi Sad
Posts: 143
Mentioned: 0 Post(s)
Quoted: 70 Post(s)
Quote:
Originally Posted by BrianTee View Post
I'm thinking that many of us don't have close by RTK bases, and moving a base around really has its disadvantages.
I have a nearby RTK base.

Quote:
So is the feeling that building an RTK base on your house etc for corrections and creating the RTCM corrections and sending them via internet to your tractor is kind of the goal here?

I only have one gnss receiver as a rover on the tractor (navspark 10 Hz) and there is a company that rents corrections for agriculture, geodesy, etc ... from its RTK base stations.


Quote:
Nice to have the whole project kind of in mind. it would seem this would be pretty ideal for most farms, all the tools i think are free, we just need to assemble.
It's a plan for the future.
ropecope is offline  
post #9 of 155 (permalink) Old 01-17-2019, 04:38 PM
Senior Member
 
Join Date: Nov 2010
Location: Dubovyy, Russian Federation
Posts: 3,286
Mentioned: 0 Post(s)
Quoted: 1070 Post(s)
Why not just run radios? I mean for the farmer that has to have their own station.
torriem likes this.
joesixpack is offline  
post #10 of 155 (permalink) Old 01-17-2019, 05:14 PM
Senior Member
 
Join Date: May 2018
Location: Serbia, Novi Sad
Posts: 143
Mentioned: 0 Post(s)
Quoted: 70 Post(s)
I think it's more stable over the Internet, I'm not sure,
Here
www.rtk2go.com
you can use their NTRIP Caster for free, but your base station is available to everyone

torriem and p00qwerty like this.
ropecope is offline  
Sponsored Links
Advertisement
 
Reply

Quick Reply
Message:
Options

Register Now



In order to be able to post messages on the The Combine Forum forums, you must first register.
Please enter your desired user name, your email address and other required details in the form below.

User Name:
Password
Please enter a password for your user account. Note that passwords are case-sensitive.

Password:


Confirm Password:
Email Address
Please enter a valid email address for yourself.

Email Address:
OR

Log-in










Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page



Similar Threads
Thread Thread Starter Forum Replies Last Post
ESPrtk 5$ for RTK positioning solution with M8P ublox or NS-HP-GL Navspark. Develop Esprtk Technology 10 01-17-2019 10:03 AM
iPad app - machine & client records - invoicing rod Custom Cutter Connection 0 05-19-2012 03:50 AM

Posting Rules  
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

 
For the best viewing experience please update your browser to Google Chrome