News:

  • June 09, 2026, 04:52:57 AM

Login with username, password and session length

Author Topic: No RC When pinging an OFFLINE PLC  (Read 19620 times)

marc.turcotte

  • Jr. Member
  • **
  • Posts: 13
No RC When pinging an OFFLINE PLC
« on: June 11, 2009, 02:15:22 PM »
Hi,

My code can be summarized to this:

I am pinging a PLC that is not even connected, and i dont get a Return code:

Code: [Select]
                        aDevices(tDevice).Address(0) = 2      ' Family= AF_INET
                        aDevices(tDevice).Address(1) = 0
                     
                        aDevices(tDevice).Address(2) = &H70   ' ECOMs use Port number 7070(Hex)
                        aDevices(tDevice).Address(3) = &H70
                     
                        aDevices(tDevice).Address(4) = 192    ' IP Address of the ECOM is 192.168.15.B
                        aDevices(tDevice).Address(5) = 168
                        aDevices(tDevice).Address(6) = 15
                        aDevices(tDevice).Address(7) = B
                       
                        'DisplayText.Text = DisplayText.Text & vbCrLf &"IP is " + Format(aDevices(tDevice).Address(4), "@@") + "." + Format(aDevices(tDevice).Address(5), "@@") + "." + Format(aDevices(tDevice).Address(6), "@@") + "." + Format(aDevices(tDevice).Address(7), "@@") + "."
                        'DisplayText.Text = DisplayText.Text & vbCrLf &"DeviceCount is " + Format(DeviceCount, "@@") + "."
                        ' Open the device
                       
                        DisplayText.Text = DisplayText.Text & vbCrLf & "------------------------------------------------------------------------------------------------"
                        DisplayText.Text = DisplayText.Text & vbCrLf & ""
                        DisplayText.Text = DisplayText.Text & vbCrLf & "[" + MyTime + "]  " + "Connecting to device ECOMBOX0" + CStr(B) + " . IP : 192.168.10." + Str(B)
                        DisplayText.Text = DisplayText.Text & vbCrLf & ""
                        DisplayText.Refresh
                        DisplayText.SelStart = Len(DisplayText.Text)
                       

                        Rc = PASCAL_HEIOpenDevice(TP, aDevices(tDevice), HEIAPIVersion, DefDevTimeout, DefDevRetrys, False)
                        If Rc <> 0 Then
                               
                                DisplayText.Text = DisplayText.Text & vbCrLf & "[" + MyTime + "]  " + "Error " + Hex(Rc) + " trying to open the device"
                                DisplayText.Text = DisplayText.Text & vbCrLf & ""
                                DisplayText.Refresh
                                DisplayText.SelStart = Len(DisplayText.Text)
                                Reading_PLC_Error = 1
                             
                        Else
                            DeviceOpen = True
                            etc....


Just above this part, i am "reseting" ( i think)  the network with the following :

Code: [Select]
                ' if the network interface has already been opened, close it
                '
                'If NetworkOK = True Then
                    Rc = PASCAL_HEICloseTransport(TP)
                    Rc = PASCAL_HEIClose()
                'End If
       
                '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                ' Initialize the Ethernet Driver
                '
                DisplayText.Text = DisplayText.Text & vbCrLf & "[" + MyTime + "]  " + "Initializing IP transfer protocol..."
                Rc = PASCAL_HEIOpen(HEIAPIVersion)
                If Rc <> 0 Then
                    DisplayText.Text = DisplayText.Text & vbCrLf & ""
                    DisplayText.Text = DisplayText.Text & vbCrLf & "[" + MyTime() + "]  " + "Error " + Hex(Rc) + " trying to initialize the Ethernet driver"
                    DisplayText.Text = DisplayText.Text & vbCrLf & ""
                    DisplayText.Refresh
                    DisplayText.SelStart = Len(DisplayText.Text)
                    Reading_PLC_Error = 1
                Else
                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                    ' Initiaizize the Winsock protocol transport
                    '
                    TP.Transport = HEIT_WINSOCK
                   
                    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                    ' Using only IP PROTOCOL
                   
                    'If UseIP = True Then
                    TP.Protocol = HEIP_IP
                    'Else
                    '    TP.Protocol = HEIP_IPX
                    'End If
                   
                    Rc = PASCAL_HEIOpenTransport(TP, HEIAPIVersion, 0)
                    If Rc <> 0 Then
                        DisplayText.Text = DisplayText.Text & vbCrLf & ""
                        DisplayText.Text = DisplayText.Text & vbCrLf & "[" + MyTime + "]  " + "Error " + Hex(Rc) + " trying to initialize the Winsock transport"
                        DisplayText.Text = DisplayText.Text & vbCrLf & ""
                        DisplayText.Refresh
                        DisplayText.SelStart = Len(DisplayText.Text)
                        Reading_PLC_Error = 1
                    Else
                        ' Using only IP PROTOCOL
                        'If UseIP = True Then
                        Pause 1 / 2
                        DisplayText.Text = DisplayText.Text & "..........INITIALIZATION COMPLETED."
                        DisplayText.Text = DisplayText.Text & vbCrLf & ""
                        DisplayText.Refresh
                        DisplayText.SelStart = Len(DisplayText.Text)
                        'Else
                        '    DisplayText.Text = DisplayText.Text & vbCrLf &"Initialized Ok, using IPX protocol"
                        'End If
                       
                        NetworkOK = True
                        'ScanNetwork.Enabled = True
                        'If Connect.Enabled = True Then Connect.Enabled = False
                                   
                        'End If
                    End If


I dont see the PLC that is offline when i query the whole network (duh!) , but when (after querying the network) i oblige the program to query the offline PLC, i dont get an error.


Thanks for your help


marc.turcotte

  • Jr. Member
  • **
  • Posts: 13
Re: No RC When pinging an OFFLINE PLC
« Reply #1 on: June 11, 2009, 04:01:53 PM »
After 2 hours of headache, i checked with the Ethernet_CCM program provided with the library... it seems that the following will NEVER have a RC different than 0... (i tried getting an error with the original EtherCCM by pinging a specific not connected address, but it seems that the program always thinks the PLC is connected)

Code: [Select]
                   Rc = PASCAL_HEIOpenDevice(TP, aDevices(tDevice), HEIAPIVersion, DefDevTimeout, DefDevRetrys, False)
                    If Rc <> 0 Then
                        DisplayText.Text = DisplayText.Text & vbCrLf & "[" + MyTime + "]  " + "Error " + Hex(Rc) + " trying to open the device..."
                        DisplayText.Text = DisplayText.Text & vbCrLf & ""
                        Reading_PLC_Error = 1
                        DisplayText.Refresh
                        DisplayText.SelStart = Len(DisplayText.Text)
                    Else
                        DeviceOpen = True


Anyways, i found out that all the others RC could return something else than 0... so i used :
Code: [Select]
Rc = PASCAL_HEIReadSetupData(aDevices(tDevice), DT_NODE_NUMBER, tBuffer(0), RSize)
and this one returns me an error.

To make sure, i kept the first part anyways ( i needed the OpenDevice = true anyways...) So my program looks like this:




Code: [Select]
                   aDevices(tDevice).Address(0) = 2      ' Family= AF_INET
                    aDevices(tDevice).Address(1) = 0
                
                    aDevices(tDevice).Address(2) = &H70   ' ECOMs use Port number 7070(Hex)
                    aDevices(tDevice).Address(3) = &H70
                
                    aDevices(tDevice).Address(4) = 192    ' IP Address of the ECOM is 192.168.15.B
                    aDevices(tDevice).Address(5) = 168
                    aDevices(tDevice).Address(6) = 15
                    aDevices(tDevice).Address(7) = B
                  
                    ' Open the device
                    
                    DisplayText.Text = DisplayText.Text & vbCrLf & "------------------------------------------------------------------------------------------------"
                    DisplayText.Text = DisplayText.Text & vbCrLf & ""
                    DisplayText.Text = DisplayText.Text & vbCrLf & "[" + MyTime + "]  " + "Connecting to device ECOMBOX0" + CStr(B) + " . IP : 192.168.10." + CStr(B)
                    DisplayText.Text = DisplayText.Text & vbCrLf & ""
                    DisplayText.Refresh
                    DisplayText.SelStart = Len(DisplayText.Text)
                    

                  
                    
                    Rc = PASCAL_HEIOpenDevice(TP, aDevices(tDevice), HEIAPIVersion, DefDevTimeout, DefDevRetrys, False)
                    If Rc <> 0 Then
                        DisplayText.Text = DisplayText.Text & vbCrLf & "[" + MyTime + "]  " + "Error " + Hex(Rc) + " trying to open the device..."
                        DisplayText.Text = DisplayText.Text & vbCrLf & ""
                        Reading_PLC_Error = 1
                        DisplayText.Refresh
                        DisplayText.SelStart = Len(DisplayText.Text)
                    Else
                        DeviceOpen = True
                        Dim tBuffer(255) As Byte
                        Dim RSize As Integer
                        Dim tstring As String
                            
                        Erase tBuffer
                        RSize = 4

                        Rc = PASCAL_HEIReadSetupData(aDevices(tDevice), DT_NODE_NUMBER, tBuffer(0), RSize)
                        If Rc <> 0 Then
                            DisplayText.Text = DisplayText.Text & vbCrLf & "[" + MyTime + "]  " + "ERROR : Connection to the PLC was lost..."
                            DisplayText.Text = DisplayText.Text & vbCrLf & ""
                            Reading_PLC_Error = 1
                            DeviceOpen = False
                          
                        Else
                            PROGRAM[...]


Feel free to comment / suggest anything else

Have a nice day
« Last Edit: June 11, 2009, 04:03:48 PM by marc.turcotte »