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(); }