Select to view content in your preferred language

NTrip - Fails writing data to NmeaDataStream

1286
10
12-13-2022 03:11 PM
JoeHershman
MVP Regular Contributor

We are trying to implement an NTrip client directly into our field application so that we have more available information and do not need the users to have a second app running in background that process the data.

I've looked at a lot of sample code including the demo app ExternalNmeaGPS.Desktop 

It all seems pretty straight forward (in a complex sort of way), but basically get the stream from the NTrip source and write it onto the device stream

I am using Runtime 100.16 in an iOS application.  Using the NmeaLocationDataSource.  When using the external application we see RTK Float fix type and I would expect to see the same in our application.  I can see that we are receiving the NTrip source stream, but there seems to be an issue in the writing. 

I get the following error in the output window when running in the debugger

Mobile.AsBuilt.iOS[30962:12345748] ERROR - /Library/Caches/com.apple.xbs/Sources/ExternalAccessory/EAOutputStream.m:-[EAOutputStream write:maxLength:] - 332 failed to write because stream does not have space available

I have searched around on this error and cannot find anything outside of one place that mentions writing to the stream on the main thread (related to a different issue) which did not change anything.

The issue looks to be occurring pretty deep into the Xamarin iOS API and not sure what could be changed on my side (or even within the EAAccessoryStream).

Unfortunately, I have some technical issues connecting the GPS device to Windows and so am not able to really test out the windows solution provided by the ExternalNmeaGPS demo app.

Thoughts?

@dotMorten_esri 

Thanks,
-Joe
0 Kudos
10 Replies
dotMorten_esri
Esri Notable Contributor

I have not tried it on an iOS device. Which receiver are you using? If I can dig one up here, I might be able to try and replicate (EAAccessoryStream is what iOS uses to connect and write to bluetooth devices)

0 Kudos
JoeHershman
MVP Regular Contributor

We have a Geneq SXBlue Platinum. 

They have an app called SX Blue Toolbox, which when connected and running is providing a RTK Float or better fix and that is seen in the application.  Most of the iOS stuff I have seen is in Objective-C (I think I saw a swift one).  So is hard to compare things directly. 

I see the output  stream is opened in the API, and seems a pretty straight forward operation to be calling Write

Thanks

Thanks,
-Joe
0 Kudos
dotMorten_esri
Esri Notable Contributor

I'm assuming you don't have the toolbox app running in the background, and blocking the write?

0 Kudos
dotMorten_esri
Esri Notable Contributor

Also make sure your receivers supports _and_ is configured to receive raw RTCM messages on its bluetooth port. Not all devices do or is by default configured for it. That's the downside of not using the proprietary apps, where it is on you to ensure the device is configured before streaming data to it.

0 Kudos
JoeHershman
MVP Regular Contributor

@dotMorten_esri I have been looking at some things, which I am not able to check directly in the API but did with the previous version of the External Accessory listener I used.

What I found is that when setup the way EAAccessoryStream is setup if you check:

_session.OutputStream.HasSpaceAvailable();

it return false and if you try and do a Write operation on the stream the errors I see the same error described above.

However, if I add

_session.OutputStream.Schedule(NSRunLoop.Current, NSRunLoopMode.Default);

Prior to calling 

_session.OutputStream.Open();

Then I am getting a true for HasSpaceAvailable(); and not seeing an error in the debug console.  I need to make some changes in my app though to truly test the correction with my old listener because of changes I made to use the API now it does not process that output completely.  In doing the testing I copied the EAAccessoryStream but with a couple changes to see what was happening

        public override void Write(byte[] buffer, int offset, int count)
        {
            if ( _session?.OutputStream == null ) return;

            bool spaceAvailable = _session.OutputStream.HasSpaceAvailable();
            Console.WriteLine($"Calling stream Write - HasSpaceAvailable = {spaceAvailable}");

            _session.OutputStream.Write(buffer, offset, (uint)count);
        }

        public override bool CanWrite => _session.OutputStream != null && _session.OutputStream.HasSpaceAvailable();

 At first I had implemented a dummy class inheriting from NSStreamDelegate and assigns as delegate, but during testing that did not seem needed, although can give some additional information

Thanks

-Joe

Thanks,
-Joe
0 Kudos
ReneParise
Emerging Contributor

To receive RTK corrections it is necessary to have a SXbluePlatinum with multifrequency, multignss and RTK activations so that it can receive and process the corrections it receives via NTRIP with SXbluetoolbox, otherwise it will remain in RTK Float without fixing the position.

https://vimeo.com/447174493 

Thanks

This is "A Platinum with Sxbluetoolbox NTRIP - ESRI Collector RTK" by Geneq INC on Vimeo, the home for high quality videos and the people who love them.
0 Kudos
ReneParise
Emerging Contributor

Hi Joe, if you use an sxblueGPS receiver you can download the SXbluetoolbox app from the iOS or Android app store and use it to process RTK corrections via NTRIP, the corrected data will be available in an app like Esri Collector, or Esri Fieldmaps in real time.

Next I leave a link showing how it works.

https://vimeo.com/447174493

Thank you

This is "A Platinum with Sxbluetoolbox NTRIP - ESRI Collector RTK" by Geneq INC on Vimeo, the home for high quality videos and the people who love them.
0 Kudos
JoeHershman
MVP Regular Contributor

@ReneParise 

We are aware of the SxToolbox app and that is the current approach being used.  We would prefer to not require the users have a second application running in the background and require them to return to this application to confirm they are connected to the NTrip server.  The client is using the SX Blue Platinum (they have over 100 devices).

The workflow of needing a second application has been arduous to the end users and we are looking for a way to have greater control within the application, giving an ability to keep the users better informed as to status of the NTrip data.

We do seem to be able to write out to the stream of the device, however, it does not seem to be returning a NMEA sentence indicating a RTK float/fix fix type.  This confusing, as it seems based on samples (including one provided by your company a few years back) we are writing the data correctly.  It is very unclear how the SxToolbox application would be writing to the device differently than how we are doing it directly from the our application.  Based on various technical documents, it seems to indicate that if an NTrip stream was being sent on the port the Platinum would recognize that it is a correction data stream.  We would love to talk with someone at Geneq that could help in this matter, you can direct message me if you could help in this regard

Thanks

-Joe

 

Thanks,
-Joe
0 Kudos
dotMorten_esri
Esri Notable Contributor

That scenario where you are trying to avoid running two apps is exactly why the option is there. However having said that, each receiver works a little different, and needs to be either manually configured correctly up front to receive RTCM and output NMEA, while others need special commands sent to them - each proprietary app knows exactly what to do with their own devices and does all this for you - once you do your own ntrip handling, it is all on you and your app to get this right.