Serial Port Timeout

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Matt Nunnally
    New Member
    • Jul 2007
    • 56

    #1

    Serial Port Timeout

    I have this code to read from a serial port. I set the timeout to 6.5 seconds. Quite often I have an issue where I don't get a response from the device because system resources are being hogged by something else. Alot of times it takes way longer than 6.5 seconds to throw the timeout exception.

    Code:
                _serialPort.ReadTimeout = 6500
                Do
                    i = _serialPort.ReadByte
                    bytes.Add(CByte(i))
                Loop Until i = 3 AndAlso _serialPort.BytesToRead = 1
    Is there a way to lock down the system resources to only be doing this loop?
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Read the serial port on its own thread for starters.

    Comment

    • Matt Nunnally
      New Member
      • Jul 2007
      • 56

      #3
      Yeah. As soon I posted this, that came to mind. So I set that up and it worked

      Comment

      Working...