CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2009
    Location
    Namibia
    Posts
    1

    C# SerialPort Class

    Q. I'm trying to write a string of characters to the serial port, which is successful, However as soon as i try and read back what has been sent, it only reads half of the the data initially sent. can anybody please help? Do i need some sort of a delay when reading or sending?

    Code:

    serialPort1.Open();
    serialPort1.Write("Communications Solutions");


    recieved_data = serialPort1.ReadExisting();

    textBox1.Text = recieved_data;

    serialPort1.Close();

    // Recieved_data only displays half the characters in the text box.

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: C# SerialPort Class

    [ moved ]
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Jul 2007
    Location
    Illinois
    Posts
    517

    Re: C# SerialPort Class

    When you send data, it uses a transmit buffer and when you receive data it uses a receive buffer. You're essentially using two different buffers for serial communication.

    If you want to get some of the data "back" that you've sent, you'll need to use whats called a null modem or use a boomerang application that will receive the data on the other end and write it back to the serial port.

    I'm studying serial communication with the 8051 architecture and it explains a lot of how serial ports work. I even have to generate my own baud rates! haha
    R.I.P. 3.5" Floppy Drives
    "I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones." - Albert Einstein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured