• <i id='fviHs'><tr id='fviHs'><dt id='fviHs'><q id='fviHs'><span id='fviHs'><b id='fviHs'><form id='fviHs'><ins id='fviHs'></ins><ul id='fviHs'></ul><sub id='fviHs'></sub></form><legend id='fviHs'></legend><bdo id='fviHs'><pre id='fviHs'><center id='fviHs'></center></pre></bdo></b><th id='fviHs'></th></span></q></dt></tr></i><div id='fviHs'><tfoot id='fviHs'></tfoot><dl id='fviHs'><fieldset id='fviHs'></fieldset></dl></div>
    <tfoot id='fviHs'></tfoot>

    <small id='fviHs'></small><noframes id='fviHs'>

      1. <legend id='fviHs'><style id='fviHs'><dir id='fviHs'><q id='fviHs'></q></dir></style></legend>
        • <bdo id='fviHs'></bdo><ul id='fviHs'></ul>


        Readline from Serial Port locks up(串行端口的读取线锁定)

        • <tfoot id='MQ0XE'></tfoot>
            1. <small id='MQ0XE'></small><noframes id='MQ0XE'>

              <legend id='MQ0XE'><style id='MQ0XE'><dir id='MQ0XE'><q id='MQ0XE'></q></dir></style></legend>
                <bdo id='MQ0XE'></bdo><ul id='MQ0XE'></ul>
                    <tbody id='MQ0XE'></tbody>

                  <i id='MQ0XE'><tr id='MQ0XE'><dt id='MQ0XE'><q id='MQ0XE'><span id='MQ0XE'><b id='MQ0XE'><form id='MQ0XE'><ins id='MQ0XE'></ins><ul id='MQ0XE'></ul><sub id='MQ0XE'></sub></form><legend id='MQ0XE'></legend><bdo id='MQ0XE'><pre id='MQ0XE'><center id='MQ0XE'></center></pre></bdo></b><th id='MQ0XE'></th></span></q></dt></tr></i><div id='MQ0XE'><tfoot id='MQ0XE'></tfoot><dl id='MQ0XE'><fieldset id='MQ0XE'></fieldset></dl></div>


                  我正在尝试从电子秤 RS232 接口读取数据.它通过我无法获取的串行端口发送一个连续的 ASCII 字符串流.我只想获取它正在发送的一行数据.我想我假设我会使用 Readline 来获取数据,但是当我运行它时它只会锁定 PC.我认为它正在尝试获取所有数据并且在数据停止之前不会停止?这是我正在使用的代码:

                  I am trying to read data from a scale RS232 interface. It sends a continuous ASCII string stream through the Serial Port which I am having trouble getting. I just want to get one line of the data that it is sending out. I guess I assumed that I would use Readline to get the data, but it just locks up the PC when I run it. I think it is trying to get all of the data and won't stop until the data stops? Here is the code I'm using:

                  private void button1_Click(object sender, EventArgs e)
                          serialPort1.PortName = "COM4";
                          serialPort1.BaudRate = 9600;
                          serialPort1.DataBits = 8;
                          serialPort1.Parity = Parity.None;
                          serialPort1.StopBits = StopBits.One;
                          //opening the serial port
                          string str = serialPort1.ReadLine();


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


                  SerialPort.ReadLine 被定义为阻止直到第一次出现 NewLine 值",其中 NewLine 默认为换行.您是否在流中发送换行符?请注意,换行符 (ASCII 0x0A) 与您可能发送的回车符 (ASCII 0x0D) 不同.

                  SerialPort.ReadLine is defined to block "up to the first occurrence of a NewLine value", where NewLine defaults to a line feed. Are you sending a linefeed in your stream? Note that a linefeed character (ASCII 0x0A) is different that a carriage return (ASCII 0x0D) that you might be sending.

                  如果需要,您可以重新定义 NewLine,或者如果行尾感觉不正确,您可以使用 SerialPort.ReadTo.您还可以设置 读取超时.

                  You can redefine the NewLine if needed, or if a line ending doesn't feel right, you can read up to a given string with SerialPort.ReadTo. You can also set a read timeout.

                  您可能更喜欢使用 SerialPort.Read 重载.

                  You might prefer to read a given number of bytes from the port, rather than a line, with one of the SerialPort.Read overloads.

                  如果这都不适用,请确保您实际上是在您认为的位置发送数据 - 调出 HyperTerminal/TeraTerm/您最喜欢的串行终端,使用与上面使用的相同的串行端口设置对其进行配置,并确保您看到您希望看到的数据.

                  If none of this applies, make sure that you're actually sending data where you think you are - bring up HyperTerminal/TeraTerm/your favorite serial terminal, configure it with the same serial port settings as you've used above, and make sure you see the data you expect to see.




                  Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)
                  Parameter count mismatch with Invoke?(参数计数与调用不匹配?)
                  How to store delegates in a List(如何将代表存储在列表中)
                  How delegates work (in the background)?(代表如何工作(在后台)?)
                  C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)
                  Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)
                • <i id='LwGW6'><tr id='LwGW6'><dt id='LwGW6'><q id='LwGW6'><span id='LwGW6'><b id='LwGW6'><form id='LwGW6'><ins id='LwGW6'></ins><ul id='LwGW6'></ul><sub id='LwGW6'></sub></form><legend id='LwGW6'></legend><bdo id='LwGW6'><pre id='LwGW6'><center id='LwGW6'></center></pre></bdo></b><th id='LwGW6'></th></span></q></dt></tr></i><div id='LwGW6'><tfoot id='LwGW6'></tfoot><dl id='LwGW6'><fieldset id='LwGW6'></fieldset></dl></div>
                  <tfoot id='LwGW6'></tfoot>

                      <legend id='LwGW6'><style id='LwGW6'><dir id='LwGW6'><q id='LwGW6'></q></dir></style></legend>

                        <bdo id='LwGW6'></bdo><ul id='LwGW6'></ul>
                          <tbody id='LwGW6'></tbody>

                        <small id='LwGW6'></small><noframes id='LwGW6'>