hhz hat geschrieben:
I have a question: How can i scan the network by Python? Because the project can not be login after network scanned . (CoDeSys version: SP9)
The API for managing gateways and scanning the network was introduced with CODESYS V3.5 SP8.
Here some example code:
\# Finddeviceobjectfound=projects.primary.find('Device', False)assert(foundandlen(found)==1, 'No or more than one device found')dev=found[0]
\# Findgatewaygw=online.gateways['Gateway-1']
\# Scannetworktargets=gw.perform_network_scan()
\# FindthetargetintheresultlistmatchingTarget=Nonefortargetintargets:
  print("Name: {} Addr: {}".format(target.device_name, target.address))
  iftarget.device_name=='KELLERMANB':
    matchingTarget=target;
    break
\# Setcomm. pathofthedeviceifmatchingTarget:
  print('Set communication path of device')
  dev.set_gateway_and_device_name(gw, target.device_name)
  # or
  # dev.set_gateway_and_address(gw, target.address)else:
  print('No matching target found')
Look for IScriptGateway, IScriptGateways and IScriptScanTargetDescription in the ScriptEngine API documentation.
BR
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I have a question: How can i scan the network by Python? Because the project can not be login after network scanned . (CoDeSys version: SP9)
Thanks!
HHZ
Hi hhz.
The API for managing gateways and scanning the network was introduced with CODESYS V3.5 SP8.
Here some example code:
Look for IScriptGateway, IScriptGateways and IScriptScanTargetDescription in the ScriptEngine API documentation.
BR
Martin