<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Help With FromSerialPort in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/help-with-fromserialport/m-p/1195954#M11170</link>
    <description>&lt;P&gt;Yes, 4800.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is how I have it working but not using the FromSerialPort. I have to use FromStreamCreator to get it to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;internal static async void Connect(Device device)
        {
            try
            {
                Disconnect();
                gpsFile = AppDomain.CurrentDomain.BaseDirectory + @"\Offline\" + Statics.App.User.Username + "_" + DateTime.Now.ToString("MM-dd-yyyy_HH-mm-ss") + ".gpsdata";
                //SERIAL PORTS
                if (device.IsSerialPort)
                {
                    string portName = "";
                    using (var ser = await Windows.Devices.SerialCommunication.SerialDevice.FromIdAsync(device.DeviceInfo!.Id))
                    {
                        portName = ser.PortName;
                    }
                    var port = new System.IO.Ports.SerialPort(portName, 4800);
                    currentGPS = NmeaLocationDataSource.FromStreamCreator(
                        onStart: (ds) =&amp;gt;
                        {
                            try
                            {
                                port.Open();
                                return Task.FromResult(port.BaseStream);
                            }
                            catch (Exception ex)
                            {
                                return null;
                            }
                        },
                        onStop: (ds) =&amp;gt;
                        {
                            try
                            {
                                port.Close();
                                return Task.CompletedTask;
                            }
                            catch (Exception ex)
                            {
                                return Task.CompletedTask;
                            }
                        }
                    );
                    pmc.MyMapView.LocationDisplay.DataSource = currentGPS;
                    pmc.MyMapView.LocationDisplay.IsEnabled = true;
                }
                else
                {
                    //BLUETOOTH
                    var btdevice = await Windows.Devices.Bluetooth.BluetoothDevice.FromIdAsync(device.DeviceInfo!.Id);
                    if (btdevice is not null)
                    {
                        currentGPS = NmeaLocationDataSource.FromBluetooth((await btdevice.GetRfcommServicesForIdAsync(RfcommServiceId.SerialPort)).Services.First());
                        pmc.MyMapView.LocationDisplay.DataSource = currentGPS;
                        pmc.MyMapView.LocationDisplay.IsEnabled = true;
                    }

                }
                currentGPS.LocationChanged += Gps_LocationChanged;
                SaveSettings(device);
                Statics.Alert("Connecting to: " + device.Name);
            }
            catch (Exception ex)
            {
                Statics.Alert(ex.Message);
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Jul 2022 15:52:02 GMT</pubDate>
    <dc:creator>pshearon</dc:creator>
    <dc:date>2022-07-26T15:52:02Z</dc:date>
    <item>
      <title>Help With FromSerialPort</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/help-with-fromserialport/m-p/1195525#M11164</link>
      <description>&lt;P&gt;.NET 6 Target 10.0.22000.0 or less&amp;nbsp; x64&lt;BR /&gt;Esri.ArcGISRuntime.WPF (100.14.1)&lt;BR /&gt;Esri.ArcGISRuntime.Toolkit (100.14.1)&lt;BR /&gt;System.IO.Ports (6.0.0)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Problem&lt;/STRONG&gt;: No response after calling&amp;nbsp;FromSerialPort with proper devices.&lt;/P&gt;&lt;P&gt;The blue-tooth devices connect properly, but I can't get any serial GPS to connect. I do not have this problem in .NET 4.8 using it's constructs (Port name).&lt;/P&gt;&lt;P&gt;Using this sample:&amp;nbsp;&lt;A href="https://github.com/Esri/arcgis-runtime-demos-dotnet/tree/main/src/ExternalNmeaGPS" target="_blank"&gt;https://github.com/Esri/arcgis-runtime-demos-dotnet/tree/main/src/ExternalNmeaGPS&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Which also exhibits the same behavior.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Patrick Shearon&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 18:09:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/help-with-fromserialport/m-p/1195525#M11164</guid>
      <dc:creator>pshearon</dc:creator>
      <dc:date>2022-07-25T18:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Help With FromSerialPort</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/help-with-fromserialport/m-p/1195713#M11168</link>
      <description>&lt;P&gt;Are you setting the correct baud rate for your device?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 00:30:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/help-with-fromserialport/m-p/1195713#M11168</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2022-07-26T00:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: Help With FromSerialPort</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/help-with-fromserialport/m-p/1195954#M11170</link>
      <description>&lt;P&gt;Yes, 4800.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is how I have it working but not using the FromSerialPort. I have to use FromStreamCreator to get it to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;internal static async void Connect(Device device)
        {
            try
            {
                Disconnect();
                gpsFile = AppDomain.CurrentDomain.BaseDirectory + @"\Offline\" + Statics.App.User.Username + "_" + DateTime.Now.ToString("MM-dd-yyyy_HH-mm-ss") + ".gpsdata";
                //SERIAL PORTS
                if (device.IsSerialPort)
                {
                    string portName = "";
                    using (var ser = await Windows.Devices.SerialCommunication.SerialDevice.FromIdAsync(device.DeviceInfo!.Id))
                    {
                        portName = ser.PortName;
                    }
                    var port = new System.IO.Ports.SerialPort(portName, 4800);
                    currentGPS = NmeaLocationDataSource.FromStreamCreator(
                        onStart: (ds) =&amp;gt;
                        {
                            try
                            {
                                port.Open();
                                return Task.FromResult(port.BaseStream);
                            }
                            catch (Exception ex)
                            {
                                return null;
                            }
                        },
                        onStop: (ds) =&amp;gt;
                        {
                            try
                            {
                                port.Close();
                                return Task.CompletedTask;
                            }
                            catch (Exception ex)
                            {
                                return Task.CompletedTask;
                            }
                        }
                    );
                    pmc.MyMapView.LocationDisplay.DataSource = currentGPS;
                    pmc.MyMapView.LocationDisplay.IsEnabled = true;
                }
                else
                {
                    //BLUETOOTH
                    var btdevice = await Windows.Devices.Bluetooth.BluetoothDevice.FromIdAsync(device.DeviceInfo!.Id);
                    if (btdevice is not null)
                    {
                        currentGPS = NmeaLocationDataSource.FromBluetooth((await btdevice.GetRfcommServicesForIdAsync(RfcommServiceId.SerialPort)).Services.First());
                        pmc.MyMapView.LocationDisplay.DataSource = currentGPS;
                        pmc.MyMapView.LocationDisplay.IsEnabled = true;
                    }

                }
                currentGPS.LocationChanged += Gps_LocationChanged;
                SaveSettings(device);
                Statics.Alert("Connecting to: " + device.Name);
            }
            catch (Exception ex)
            {
                Statics.Alert(ex.Message);
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 15:52:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/help-with-fromserialport/m-p/1195954#M11170</guid>
      <dc:creator>pshearon</dc:creator>
      <dc:date>2022-07-26T15:52:02Z</dc:date>
    </item>
  </channel>
</rss>

