Problem with serial port data receive in C#

前端 未结 6 1968
梦谈多话
梦谈多话 2021-01-15 21:40

I have a problem with a C# program. Through the Serial port i Receive a large string about 110 characters. This part works ok, but when i add code to split the string up i r

6条回答
  •  没有蜡笔的小新
    2021-01-15 22:14

    The exception is telling you that, at some point, Substring is being given parameters that exceed the length of the string. Which likely means you aren't getting the data you are expecting from the serial port. Try inserting a breakpoint at the first call to Substring and check the contents of data to make sure the device you are reading from isn't sending some kind of error code or something other than what your code expects.

提交回复
热议问题