Created
August 24, 2017 02:18
-
-
Save jfach/97620f1a28bf830b6c49b1ccb4f33497 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
import minimalmodbus | |
import sys | |
SERIAL_PORT = '/' | |
DEVICE_ADDRESS = 1 | |
DECIMAL_COUNT = 1 | |
def modbus_RTU(): | |
try: | |
device = minimalmodbus.Instrument(SERIAL_PORT, DEVICE_ADDRESS) | |
r1_value = device.read_register(1, DECIMAL_COUNT) | |
r3_value = device.read_register(3, DECIMAL_COUNT) | |
print r1_value | |
print r3_value | |
except IOError: | |
print "communication error with device" | |
sys.exit(1) | |
if __name__ == "__main__": | |
modbus_RTU() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment