-
Notifications
You must be signed in to change notification settings - Fork 605
Open
Labels
Description
Describe the bug
The NMEA string produced by WaterSpeedAndAngle has degree signs in it eg. $ECVHW,,T,45.5 °,M,24.0,N,44.4,K,*F7
Steps to reproduce
// put sample code here
WaterSpeedAndAngle vhw = new WaterSpeedAndAngle(null, UnitsNet.Angle.FromDegrees(45.5), UnitsNet.Speed.FromKnots(44.4));
var s = vhw.ToNmeaMessage();
Expected behavior
s should be $ECVHW,,T,45.5,M,24.0,N,44.4,K,*F7
Actual behavior
$ECVHW,,T,45.5 °,M,24.0,N,44.4,K,*F7
it is caused by
https://github.com/dotnet/iot/blob/ae707ec89735bdac46346cb15b2296adf23b5079/src/devices/Nmea0183/Sentences/WaterSpeedAndAngle.cs#L124C16-L127C1
this fixes it
// It seems that angles should always be written 0..360.
string normalizedT = HeadingTrue.HasValue ? HeadingTrue.Value.Normalize(true).Degrees.ToString("F1", CultureInfo.InvariantCulture) : string.Empty;
string normalizedM = HeadingMagnetic.HasValue ? HeadingMagnetic.Value.Normalize(true).Degrees.ToString("F1", CultureInfo.InvariantCulture) : string.Empty;
Versions used