python use variable in Modbusclient

216 Views Asked by At

I am having an issue with using a variable in a function.

ports = ["'/dev/ttyXRUSB0'","'/dev/ttyXRUSB1'"]
for item in ports:
  print len(ports)
  #port = item
  print item 
  client = ModbusClient(method = 'rtu', port = item, baudrate = 115200, timeout = 0.2)
  print client
  client.connect()

I want to see client = ModbusClient(method = 'rtu', port = '/dev/ttyXRUSB0' baudrate = 115200, timeout = 0.2)

Where am i messing this up?

0

There are 0 best solutions below