mirror of
https://github.com/dotMorten/NmeaParser.git
synced 2025-12-06 07:12:04 +01:00
parent
40f2bdc4a6
commit
8e89abaca3
|
|
@ -437,7 +437,7 @@ namespace NmeaParser.Gnss
|
||||||
/// <seealso cref="IsFixValid"/>
|
/// <seealso cref="IsFixValid"/>
|
||||||
public event EventHandler? LocationLost;
|
public event EventHandler? LocationLost;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Occurs when a property value changes.</summary>
|
||||||
public event PropertyChangedEventHandler? PropertyChanged;
|
public event PropertyChangedEventHandler? PropertyChanged;
|
||||||
|
|
||||||
private void OnPropertyChanged(IEnumerable<string> properties)
|
private void OnPropertyChanged(IEnumerable<string> properties)
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,10 @@ namespace NmeaParser.Messages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>
|
||||||
|
/// Returns a string that represents the satellite vehicle.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A string that represents the satellite vehicle.</returns>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
switch (TalkerId)
|
switch (TalkerId)
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,10 @@ namespace NmeaParser.Messages
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsProprietary => MessageType[0] == 'P'; //Appendix B
|
public bool IsProprietary => MessageType[0] == 'P'; //Appendix B
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>
|
||||||
|
/// Returns the original NMEA string that represents this message.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>An original NMEA string that represents this message.</returns>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return string.Format(CultureInfo.InvariantCulture, "${0},{1}*{2:X2}", MessageType, string.Join(",", MessageParts), Checksum);
|
return string.Format(CultureInfo.InvariantCulture, "${0},{1}*{2:X2}", MessageType, string.Join(",", MessageParts), Checksum);
|
||||||
|
|
@ -301,7 +304,11 @@ namespace NmeaParser.Messages
|
||||||
return TimeSpan.Zero;
|
return TimeSpan.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>
|
||||||
|
/// Indicates whether the current object is equal to another object of the same type.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="other">An object to compare with this object.</param>
|
||||||
|
/// <returns><c>true</c> if the current object is equal to the other parameter; otherwise, <c>false</c>.</returns>
|
||||||
public bool Equals(NmeaMessage other)
|
public bool Equals(NmeaMessage other)
|
||||||
{
|
{
|
||||||
if (other.MessageType != MessageType)
|
if (other.MessageType != MessageType)
|
||||||
|
|
|
||||||
|
|
@ -12,22 +12,22 @@
|
||||||
// * limitations under the License.
|
// * limitations under the License.
|
||||||
// ******************************************************************************
|
// ******************************************************************************
|
||||||
|
|
||||||
#if WINDOWS_UWP
|
#if WINDOWS_UWP
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Windows.Devices.SerialCommunication;
|
using Windows.Devices.SerialCommunication;
|
||||||
using System.Runtime.InteropServices.WindowsRuntime;
|
using System.Runtime.InteropServices.WindowsRuntime;
|
||||||
|
|
||||||
namespace NmeaParser
|
namespace NmeaParser
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A Serial Port NMEA device
|
/// A Serial Port NMEA device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// To use the NMEA Parser against a serial device in a Windows 10 Universal app, ensure the serial device capability is enabled by opening package.appxmanifest in a text editor, and add the following to the <c><Capabilities></c> section:
|
/// To use the NMEA Parser against a serial device in a Windows 10 Universal app, ensure the serial device capability is enabled by opening package.appxmanifest in a text editor, and add the following to the <c><Capabilities></c> section:
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -37,8 +37,8 @@ namespace NmeaParser
|
||||||
/// <Function Type="name:serialPort" />
|
/// <Function Type="name:serialPort" />
|
||||||
/// </Device>
|
/// </Device>
|
||||||
/// </DeviceCapability>
|
/// </DeviceCapability>
|
||||||
/// </code>
|
/// </code>
|
||||||
/// <code lang="cs">
|
/// <code lang="cs">
|
||||||
/// var selector = SerialDevice.GetDeviceSelector("COM3"); //Get the serial port on port '3'
|
/// var selector = SerialDevice.GetDeviceSelector("COM3"); //Get the serial port on port '3'
|
||||||
/// var devices = await DeviceInformation.FindAllAsync(selector);
|
/// var devices = await DeviceInformation.FindAllAsync(selector);
|
||||||
/// if(devices.Any()) //if the device is found
|
/// if(devices.Any()) //if the device is found
|
||||||
|
|
@ -58,64 +58,64 @@ namespace NmeaParser
|
||||||
/// {
|
/// {
|
||||||
/// // called when a message is received
|
/// // called when a message is received
|
||||||
/// }
|
/// }
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public class SerialPortDevice : NmeaDevice
|
public class SerialPortDevice : NmeaDevice
|
||||||
{
|
{
|
||||||
private SerialDevice m_port;
|
private SerialDevice m_port;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="SerialPortDevice" /> class.
|
/// Initializes a new instance of the <see cref="SerialPortDevice" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="device">The serial port.</param>
|
/// <param name="device">The serial port.</param>
|
||||||
/// <exception cref="System.ArgumentNullException">port</exception>
|
/// <exception cref="ArgumentNullException">port</exception>
|
||||||
public SerialPortDevice(SerialDevice device)
|
public SerialPortDevice(SerialDevice device)
|
||||||
{
|
{
|
||||||
if (device == null)
|
if (device == null)
|
||||||
throw new ArgumentNullException("device");
|
throw new ArgumentNullException("device");
|
||||||
m_port = device;
|
m_port = device;
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the active serial port.
|
|
||||||
/// </summary>
|
|
||||||
public SerialDevice SerialDevice
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return m_port;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override Task<System.IO.Stream> OpenStreamAsync()
|
|
||||||
{
|
|
||||||
return Task.FromResult<System.IO.Stream>(m_port.InputStream.AsStreamForRead(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override Task CloseStreamAsync(System.IO.Stream stream)
|
|
||||||
{
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Writes data to the serial port (useful for RTCM/dGPS scenarios)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="buffer">The byte array that contains the data to write to the port.</param>
|
|
||||||
/// <param name="offset">The zero-based byte offset in the buffer parameter at which to begin copying
|
|
||||||
/// bytes to the port.</param>
|
|
||||||
/// <param name="count">The number of bytes to write.</param>
|
|
||||||
[Obsolete("Use WriteAsync")]
|
|
||||||
public void Write(byte[] buffer, int offset, int count)
|
|
||||||
{
|
|
||||||
m_port.OutputStream.AsStreamForWrite().Write(buffer, offset, count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>
|
||||||
|
/// Gets the active serial port.
|
||||||
|
/// </summary>
|
||||||
|
public SerialDevice SerialDevice
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_port;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override Task<System.IO.Stream> OpenStreamAsync()
|
||||||
|
{
|
||||||
|
return Task.FromResult<System.IO.Stream>(m_port.InputStream.AsStreamForRead(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override Task CloseStreamAsync(System.IO.Stream stream)
|
||||||
|
{
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Writes data to the serial port (useful for RTCM/dGPS scenarios)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="buffer">The byte array that contains the data to write to the port.</param>
|
||||||
|
/// <param name="offset">The zero-based byte offset in the buffer parameter at which to begin copying
|
||||||
|
/// bytes to the port.</param>
|
||||||
|
/// <param name="count">The number of bytes to write.</param>
|
||||||
|
[Obsolete("Use WriteAsync")]
|
||||||
|
public void Write(byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
m_port.OutputStream.AsStreamForWrite().Write(buffer, offset, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public override bool CanWrite => true;
|
public override bool CanWrite => true;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override Task WriteAsync(byte[] buffer, int offset, int length)
|
public override Task WriteAsync(byte[] buffer, int offset, int length)
|
||||||
{
|
{
|
||||||
if (m_port == null)
|
if (m_port == null)
|
||||||
|
|
@ -123,6 +123,6 @@ namespace NmeaParser
|
||||||
|
|
||||||
return m_port.OutputStream.WriteAsync(buffer.AsBuffer(offset, length)).AsTask();
|
return m_port.OutputStream.WriteAsync(buffer.AsBuffer(offset, length)).AsTask();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Loading…
Reference in a new issue