Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Set up the gateway and device by IP address and device address

chenhe
2017-03-14
2022-05-04
  • chenhe

    chenhe - 2017-03-14

    Hi there,

    I wonder if it is possible now to set up the gateway and device by IP address and device address?
    I have looked up on the forum and in the ScriptEngine.chm. The only way I found was to use the device name, shown below.

    Zitat:
    projects.primary.find("Device name", True)
    get_gateway()
    get_address()
    set_gateway_and_address(gateway, address)

    Thank you in advance

     
  • mkeller

    mkeller - 2017-03-14

    Hi chenhe.

    chenhe hat geschrieben:
    I wonder if it is possible now to set up the gateway and device by IP address and device address?
    I have looked up on the forum and in the ScriptEngine.chm. The only way I found was to use the device name, shown below.

    With CODESYS V3.5 SP9 or newer you can use the method to specify the IP address for the device.

    You can find your gateway object by its name with the following code:

    gw = online.gateways['Gateway-1']
    

    If you don't have a gateway you can create one with . You need to create a dictionary with the parameters required by the gateway driver. Each parameter must be converted to match the required type in the driver. I can provide an example if you need one.

    BR
    Martin

     
  • chenhe

    chenhe - 2017-03-16

    Hello M.Keller,

    I'd like to have the example for creating new gateway. Thanks again.

    M.Keller hat geschrieben:
    If you don't have a gateway you can create one with . You need to create a dictionary with the parameters required by the gateway driver. Each parameter must be converted to match the required type in the driver. I can provide an example if you need one.

     
  • mkeller

    mkeller - 2017-03-16

    Hi chenhe.

    chenhe hat geschrieben:
    I'd like to have the example for creating new gateway.

    I attached an example for creating a gateway.

    BR
    Martin

    gateway_add_new.py [889 Bytes]

     
    • tusharb

      tusharb - 2022-05-04

      Your code will add only new Gateway. Do you know how to set default device to that gateway using Python script?

       

Log in to post a comment.