pjkundert / cpppo

Communications Protocol Python Parser and Originator -- EtherNet/IP CIP
https://hardconsulting.com/products/6-cpppo-enip-api
Other
328 stars 108 forks source link

(Question) Duplicate Responses to CIP Discovery Packet #108

Closed JL00001 closed 2 years ago

JL00001 commented 2 years ago

I am using CPPPO to simulate a PowerFlex 525. I am also using pycomm3 to craft the CIP Read/Write packets; (I found pycomm3 first). Pycomm3 has a CIP Discovery method, and it is able to see the simulated drive I created, but it seems to return 3 devices instead of 1

Screenshot of it happening:

Screenshot from 2022-03-15 11-24-50

My Simulated Drive Code:

import sys, logging
from Excel_Dump_Lables import Lables
from cpppo.server import enip
from cpppo.server.enip.main import main as enip_main

class DPI_Parameters( enip.Object ):
    class_id            = 0x93
    def __init__( self, name=None, **kwds ):
        super( DPI_Parameters, self ).__init__( name=name, **kwds )
        if self.instance_id == 0:
            pass
        else:
            self.attribute['9']= enip.Attribute( Lables[self.instance_id],  enip.INT, default=self.instance_id )      

def main( **kwds ):
    enip.config_files          += [ __file__.replace( '.py', '.cfg' ) ]
    for x in range(1,731):
        DPI_Parameters( name="DPI_Parameters", instance_id=x )
    return enip_main( argv=sys.argv[1:])

sys.exit( main( attribute_class=main,argv=sys.argv[1:]))

Drive Config File:

[Identity]
Product Name                = PowerFlex 525

[TCPIP]
Interface Status            = 2  # (Hardware configured)
Configuration Capability    = 48 # (Config Settable, Hardware Settable)
Configuration Control       = 16 # Statically assigned IP, DNS Eanbled
Host Name               = PowerFlexSimDrive
Path to Physical Link       = [
                            { "class":     246 },
                            { "instance":    1 }
                              ]

Interface Configuration     = {
        "ip_address":       "192.168.1.143",
        "gateway_address":  "192.168.1.1",
        "network_mask":     "255.255.255.0",
        "dns_primary":      "1.1.1.1",
        "dns_secondary":    "8.8.8.8",
        "domain_name":      "example.com"
    }

[UCMM]

"Route Path"                = false

My Question: Is there a way to check that I am not accidentally spawning more than one drive process?

Or if there is something glaringly wrong with my code

pjkundert commented 2 years ago

It looks like 2 responses, not 3... Well, cpppo does bind to both the UDP and TCP port, so perhaps pycomm3 is finding the device on both UDP and TCP? I think Cpppo only does a broadcast request on either TCP or UDP, not both.

Just a guess...

JL00001 commented 2 years ago

Would there be a way to tell the simulated PowerFlex drive to not respond to TCP packets? As to test that theory?

JL00001 commented 2 years ago

image image I think you are right. It is probably operating on both TCP and UDP