tomi jana

tomi jana

  • NA
  • 1
  • 0

Serial port - some problems

Oct 13 2009 10:12 AM
I'm writing program, which is to transmit data between two ports RS-232 and display them.
Basically working, but on some computers transmit and display correctly only the first two characters and then receives incorrect data from the RS-232 port.

I suspect that this may be a problem with the theme SerialDataReceivedEventHandler (this.RS1rx). Is this thread should be blocked to run only once, or some other way to control him?
Do you have any idea?


Here is my configuration and function of the reception for one of the ports, second is the same.

                 RS1 = new SerialPort(RS1cb.SelectedItem.ToString(), System.Int32.Parse(RSspeedcb.Text.ToString()), Parity.None, 8, StopBits.One);


                RS1.Handshake = Handshake.None;
                RS1.WriteBufferSize = 200;
                RS1.ReadBufferSize = 200;
//                RS1.ReceivedBytesThreshold = 4;
                this.RS1.DataReceived += new SerialDataReceivedEventHandler(this.RS1rx);
                RS1.Open();

        private void RS1rx(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
        {
//            Thread.Sleep(200);

               string data = RS1.ReadExisting();
               RS2.WriteLine(data);

               txtLog.Invoke(new SetTextDeleg(SetText), new object[] { data });

        }


Answers (1)