Set gateway and default path

chab
2012-04-16
2012-04-17
  • chab - 2012-04-16

    Does CoDeSys provide the possibility to set the gateway (e.g. IP number) and scan the network for devices, by python script.

    In the examples, I see no gateway IP number at all. While in the GUI, I have to select a gateway and set the active path.
    e.g.
    # set "Python.project" to active application
    app = proj.active_application
    onlineapp = online.create_online_application(app)
    # login to device
    onlineapp.login(OnlineChangeOption.Try, True)

    The goal is to give a script two parameters (project name and gateway IP number). And that script would download the project to that device. (The project itself does not contain the gateway information.)

     
  • Anonymous - 2012-04-16

    Originally created by: M.Schaber

    Hi, Edwin,

    Edwin hat geschrieben:
    Does CoDeSys provide the possibility to set the gateway (e.g. IP number) and scan the network for devices, by python script.
    In the examples, I see no gateway IP number at all. While in the GUI, I have to select a gateway and set the active path.
    e.g.
    # set "Python.project" to active application
    app = proj.active_application
    onlineapp = online.create_online_application(app)
    # login to device
    onlineapp.login(OnlineChangeOption.Try, True)
    The goal is to give a script two parameters (project name and gateway IP number). And that script would download the project to that device. (The project itself does not contain the gateway information.)

    For scripts, device Objects have the following methods:

    get_gateway() # Returns the Guid of the Gateway
    get_address() # Returns the device address as a string.
    set_gateway_and_address(gateway, address) # Sets the gateway and address for this device. (gateway can be a Guid object or the string representation of a Guid.)
    

    So you can set the gateway and address CoDeSys uses to connect to a specific device, the "active path". The adress here is the CoDeSys address (like "[011D.8001.9ED4]") and not an IP address, as it has to cover routing through several cascaded field busses.

    Sadly, the Guid is not yet displayed anywhere in the UI. The easiest way to get the Guid for a Gateway currently is to set the active path of a device to that gateway, and then dump it via "print projects.primary.find("name_of_device", True)[0].get_gateway()" in a script.

    It is not yet possible to configure the list of available Gateways itsself (like the "Add Gateway" button) from the script, however. If you need this functionality, please file it as a requirement via our support department.

     
  • chab - 2012-04-17

    I used:

    controller = projects.primary.find("CoDeSys_Control", True)[0]
    pprint.pprint (controller)
    deviceidΒ  Β  Β  = controller.get_device_identification()
    devicegateway = controller.get_gateway()
    deviceaddress = controller.get_address()
    pprint.pprint (devicegateway)
    

    And that resulted in a 16 byte GUID.

    Next I'll try to set the controller communication setting...

    Also I detected that the Menu; Project; Export file contains the GatewayGuid.
    Search for <single type="System.Guid" name="GatewayGuid"> in the *.export file.</single>

     

Log in to post a comment.