Hi all,
I'm doing some tests with my Netduino 3's UART ports, and I've come across something weird.
When doing a loopback on any serial port, the second byte that was written to the port, is missing from the bytes read back from that same (or other, doesn't matter) port.
Simplified code snippet:
namespace NetduinoApplication4 { public class Program { public static void Main() { var sp = new SerialPort(SerialPorts.COM1, 2400, Parity.None, 8, StopBits.One); sp.Open(); var writeBuffer = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05 }; var readBuffer = new byte[writeBuffer.Length]; while (true) { sp.Write(writeBuffer, 0, writeBuffer.Length); sp.Flush(); var read = sp.Read(readBuffer, 0, readBuffer.Length); Debug.Print("Read: " + readBuffer[0] + " " + readBuffer[1] + " " + readBuffer[2] + " " + readBuffer[3] + " " + readBuffer[4]); Thread.Sleep(1000); } } } }
Output:
Read: 1 3 4 5 0 Read: 1 3 4 5 0 Read: 1 3 4 5 0
Of course, I'm expecting those lines to read "1 2 3 4 5". Also, the variable "read" is set to 4, instead of the expected 5.
I can reproduce this on every COM port and with different array sizes.
Netduino deploy tool output:
HalSystemInfo.halVersion: 4.3.1.0 HalSystemInfo.halVendorInfo: Netduino 3 (v4.3.2.2) by Secret Labs LLC HalSystemInfo.oemCode: 34 HalSystemInfo.modelCode: 177 HalSystemInfo.skuCode: 4103 HalSystemInfo.moduleSerialNumber: 00000000000000000000000000000000 HalSystemInfo.systemSerialNumber: 0000000000000000 ClrInfo.clrVersion: 4.3.1.0 ClrInfo.clrVendorInfo: Netduino 3 (v4.3.2.2) by Secret Labs LLC ClrInfo.targetFrameworkVersion: 4.3.1.0 SolutionReleaseInfo.solutionVersion: 4.3.2.2 SolutionReleaseInfo.solutionVendorInfo: Netduino 3 (v4.3.2.2) by Secret Labs LLC SoftwareVersion.BuildDate: Jul 14 2015 SoftwareVersion.CompilerVersion: 410894
Am I doing something wrong, or is this a bug?
- shockckcHok likes this