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

UART Flow Control


  • Please log in to reply
No replies to this topic

#1 Saturnim

Saturnim

    Member

  • Members
  • PipPip
  • 12 posts

Posted 07 June 2011 - 07:59 PM

Hi!
I have problem with flow control in serialPort. I am using FTDI cabel and I have connected it in this way : Tx<->Rx, CTS <-> RTS.I set handshake as request to send. In uC side I dont recive data because of I want to full up buffer. On PC side I send a lot of data in loop. I expected some error or stop of program on Write method, but PC all the time can to send data though full receiver buffor.
uC
        public static SerialPort RS;
        public static void Main()
        {
            RS = new SerialPort("COM1", 9600);
            RS.Handshake = Handshake.RequestToSend;
            //RS.DataReceived += new SerialDataReceivedEventHandler(RS_DataReceived);
            RS.Open();
            Thread.Sleep(Timeout.Infinite);
        }

        static void RS_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            byte[] inpuBuffer = new byte[RS.BytesToRead];
            RS.Read(inpuBuffer, 0, inpuBuffer.Length);
        }

PC
private static SerialPort RS;       
        static void Main(string[] args)
        {
            RS = new SerialPort("COM3", 9600);
            RS.Handshake = Handshake.RequestToSend;
            RS.WriteTimeout = Timeout.Infinite;
            
            RS.DataReceived += new SerialDataReceivedEventHandler(RS_DataReceived);
            RS.ErrorReceived += new SerialErrorReceivedEventHandler(RS_ErrorReceived);
            RS.DtrEnable = true;
            RS.RtsEnable = true;

            byte[] bytes = new byte[1024];

            for (int i = 0; i < bytes.Length; i++)
            {
                bytes[i] = (byte)i;
            }
            RS.Open();

            while (true)
            {
                RS.Write(bytes, 0, bytes.Length);
            }
        }

        static void RS_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
        {
            throw new NotImplementedException();
        }

        static void RS_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            //throw new NotImplementedException();
        }





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.