c# - Readline from Serial Port locks up -


I am trying to read data from a scale RS232 interface. It sends a continuous ASCII string stream through the serial port, for which I'm having trouble. I just have to get a line of data that he's sending out. I think I think I will use the readline to get the data, but when I lock the PC to run it I think that it is trying to get all data and as long as the data is off Will not stop until it goes? Here's the code I am using:

  Private Zero Button 1_Click (Object Sender, EventArgs e) {serialPort1.PortName = "COM4"; SerialPort1.BaudRate = 9600; SerialPort1.DataBits = 8; SerialPort1.Parity = Equality One; SerialPort1.StopBits = StopBits.One; // serial port serialPort1 opening. open (); String str = serialPort1.ReadLine (); MessageBox.Show (STR); SerialPort1.Close (); }  

Can you help me determine how to get a line of output data and close the connection?

is defined to "block the first occurrence of a new line", where one Delay in row feed Are you sending linefeed in your stream? Note that a linefeed character (ASCII0x0A) is a carriage return (ASCII 0x0D) that you can send.

If needed, you can redefine Newlines, or if the end of a line does not seem right, you can read a given string together. You can also do a set.

You may like to read the bytes from the burden, with an olload, instead of one line.

If none of this is applicable, make sure that you are actually sending data where you are thinking - Bring the HyperTerminal / TerraTerm / your favorite serial terminal to the same serial port settings Expect to see as you have shown above, and to make sure that you see the data you see.


Comments