Skip to content

Instantly share code, notes, and snippets.

@bashwork
Created July 9, 2013 15:42
Show Gist options
  • Save bashwork/f6c1c67375b9fd88de22 to your computer and use it in GitHub Desktop.
Save bashwork/f6c1c67375b9fd88de22 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from pymodbus.client.sync import ModbusTcpClient
import logging
logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.DEBUG)
client = ModbusTcpClient('xxx.xxx.xxx.xxx', port=50002)
connected = client.connect()
print("client connected: %s" % connected)
rq = client.write_coil(5, True)
assert(rq != None)
assert(rq.function_code < 0x80)
rr = client.read_coils(5,1)
assert(rr != None)
assert(rr.bits[0] == True)
client.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment