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"/>
|
||||
public event EventHandler? LocationLost;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Occurs when a property value changes.</summary>
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
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()
|
||||
{
|
||||
switch (TalkerId)
|
||||
|
|
|
|||
|
|
@ -233,7 +233,10 @@ namespace NmeaParser.Messages
|
|||
/// </summary>
|
||||
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()
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "${0},{1}*{2:X2}", MessageType, string.Join(",", MessageParts), Checksum);
|
||||
|
|
@ -301,7 +304,11 @@ namespace NmeaParser.Messages
|
|||
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)
|
||||
{
|
||||
if (other.MessageType != MessageType)
|
||||
|
|
|
|||
|
|
@ -12,22 +12,22 @@
|
|||
// * limitations under the License.
|
||||
// ******************************************************************************
|
||||
|
||||
#if WINDOWS_UWP
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Devices.SerialCommunication;
|
||||
#if WINDOWS_UWP
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Devices.SerialCommunication;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
|
||||
namespace NmeaParser
|
||||
namespace NmeaParser
|
||||
{
|
||||
/// <summary>
|
||||
/// A Serial Port NMEA device
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <summary>
|
||||
/// A Serial Port NMEA device
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <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:
|
||||
/// </para>
|
||||
|
|
@ -37,8 +37,8 @@ namespace NmeaParser
|
|||
/// <Function Type="name:serialPort" />
|
||||
/// </Device>
|
||||
/// </DeviceCapability>
|
||||
/// </code>
|
||||
/// <code lang="cs">
|
||||
/// </code>
|
||||
/// <code lang="cs">
|
||||
/// var selector = SerialDevice.GetDeviceSelector("COM3"); //Get the serial port on port '3'
|
||||
/// var devices = await DeviceInformation.FindAllAsync(selector);
|
||||
/// if(devices.Any()) //if the device is found
|
||||
|
|
@ -58,64 +58,64 @@ namespace NmeaParser
|
|||
/// {
|
||||
/// // called when a message is received
|
||||
/// }
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
public class SerialPortDevice : NmeaDevice
|
||||
{
|
||||
private SerialDevice m_port;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SerialPortDevice" /> class.
|
||||
/// </summary>
|
||||
/// <param name="device">The serial port.</param>
|
||||
/// <exception cref="System.ArgumentNullException">port</exception>
|
||||
public SerialPortDevice(SerialDevice device)
|
||||
{
|
||||
if (device == null)
|
||||
throw new ArgumentNullException("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);
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
public class SerialPortDevice : NmeaDevice
|
||||
{
|
||||
private SerialDevice m_port;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SerialPortDevice" /> class.
|
||||
/// </summary>
|
||||
/// <param name="device">The serial port.</param>
|
||||
/// <exception cref="ArgumentNullException">port</exception>
|
||||
public SerialPortDevice(SerialDevice device)
|
||||
{
|
||||
if (device == null)
|
||||
throw new ArgumentNullException("device");
|
||||
m_port = device;
|
||||
}
|
||||
|
||||
/// <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;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <inheritdoc />
|
||||
public override Task WriteAsync(byte[] buffer, int offset, int length)
|
||||
{
|
||||
if (m_port == null)
|
||||
|
|
@ -123,6 +123,6 @@ namespace NmeaParser
|
|||
|
||||
return m_port.OutputStream.WriteAsync(buffer.AsBuffer(offset, length)).AsTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Loading…
Reference in a new issue