Author Topic: Program locks up if connection is interrupted  (Read 2348 times)

bachphi

  • Hero Member
  • *****
  • Posts: 642
    • View Profile
Re: Program locks up if connection is interrupted
« Reply #30 on: April 23, 2023, 04:32:49 PM »
It appears there is a bug in the timeout of the ping command, anything less than 500 ms will default to 500ms. It will work with multiples of 500 ms.

Are you going to test out the new driver?

Code: [Select]
    Dim PingSender As Ping = New Ping()
    Dim PLCIsConnected As Boolean() = Nothing

    Dim lines() As String = ReadAllLines(".\PLCDevicesList.txt")
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Debug.Print(DateTime.Now())
        Dim i As Integer = 0
        ReDim PLCIsConnected(lines.Count() - 1)
        For Each lineItem In lines
            Dim PingResponse As PingReply = PingSender.Send(lineItem, 500, Encoding.ASCII.GetBytes(1), New PingOptions(64, True))
            If PingResponse.Status = IPStatus.Success Then
                PLCIsConnected(i) = 1
            Else
                PLCIsConnected(i) = 0
            End If
            i = i + 1

        Next
        Debug.Print(DateTime.Now())
    End Sub


Archie,  how about adding a function 'IsConnected' to the driver?  Other drivers I have seen, they all have that  feature.
« Last Edit: April 23, 2023, 05:06:14 PM by bachphi »
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

lpou

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Program locks up if connection is interrupted
« Reply #31 on: April 24, 2023, 12:52:41 PM »
I agree, You would have to create the IsConnected property in the drivers, to avoid the execution of read or write in the plc, if there is no connection, and thus avoid delay times.