Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,9 @@ public static byte[] ToBuffer(long reading)
bytes = BitConverter.GetBytes((int)reading);
bytes.CopyTo(allBytes, 1);
}
else if (reading > Int16.MaxValue)
{
allBytes[0] = 0x2;
bytes = BitConverter.GetBytes((ushort)reading);
bytes.CopyTo(allBytes, 1);
}
else if (reading >= 0)
{
allBytes[0] = 0xfe;
allBytes[0] = 0x2;
bytes = BitConverter.GetBytes((ushort)reading);
bytes.CopyTo(allBytes, 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ public void ToBuffer_lower_ushort()
public void ToBuffer_upper_short()
{
var bytes = TelemetryBuffer.ToBuffer(Int16.MaxValue);
Assert.Equal(new byte[] { 0xfe, 0xff, 0x7f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, bytes);
Assert.Equal(new byte[] { 0x2, 0xff, 0x7f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, bytes);
}

[Fact]
[Task(1)]
public void ToBuffer_Zero()
{
var bytes = TelemetryBuffer.ToBuffer(0);
Assert.Equal(new byte[] { 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, bytes);
Assert.Equal(new byte[] { 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, bytes);
}

[Fact]
Expand Down