-
-
Save bashwork/f6c1c67375b9fd88de22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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