TimeoutException called

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • darjonase@gmail.com

    #1

    TimeoutException called

    Alright, here is my issue. I am using the IO.Ports.Serial Port namespace
    for the following method. In a previous method, I already set the
    serial port up using the proper baudrate, parity, etc.

    The issue I am having is that the code will execute fine the first time
    it runs through, but any time after that it is called, the timeout
    exception occurs. Any ideas on why this might happen?

    Here is the code...

    Public Sub GetSonyGageValu es(ByVal serialPort As IO.Ports.Serial Port)
    Try
    Dim byteArrList As New ArrayList
    Dim intCheckSum As Integer

    byteArrList.Cle ar()
    intCheckSum = 0

    serialPort.Read Timeout = 500
    serialPort.Writ eTimeout = 50

    serialPort.Disc ardInBuffer()
    serialPort.Writ e("R" & vbCrLf)

    Dim strData As String = serialPort.Read Line

    If strData.Length 0 Then
    Dim tempArray() As String

    'parses out the information gathered from the COM port
    to a temp location
    tempArray =
    Split(strData.T rimEnd(vbCrLf). TrimEnd(vbCr), " ")

    Dim intloop As Integer
    For intloop = 0 To tempArray.Lengt h - 1
    Dim arrLoc As Integer = CInt("&h" &
    Hex(tempArray(i ntloop).Substri ng(0, 2)))
    If InStr(tempArray (intloop).Subst ring(5, 8),
    "Error") Then
    sngSonyValues(a rrLoc) = 4096
    Else
    If tempArray(intlo op).Substring(5 , 1) = "+"
    Then
    sngSonyValues(a rrLoc) =
    CSng(tempArray( intloop).Substr ing(6, 7))
    Else
    sngSonyValues(a rrLoc) =
    CSng(tempArray( intloop).Substr ing(5, 8))
    End If
    End If
    Next
    End If
    Catch tex As TimeoutExceptio n
    _boolMuxError = True
    InputBadReading s()
    Catch ioex As IO.IOException
    'do nothing as this may occur when going into calibration
    Catch invalopEx As System.InvalidO perationExcepti on
    'do nothing as this may occur when going into calibration
    Catch ex As Exception
    tListener.AddMe thodError(ex)
    End Try
    End Sub

Working...