Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

[N3] Serial loopback: second byte missing


  • Please log in to reply
No replies to this topic

#1 Michiel

Michiel

    Member

  • Members
  • PipPip
  • 13 posts
  • LocationZwolle, The Netherlands

Posted 26 March 2016 - 11:06 PM

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?  :o






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.