Created
July 28, 2023 06:58
-
-
Save JeonghunLee/296262b5792d242f10197f001023626b to your computer and use it in GitHub Desktop.
modbus_rtu_example
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
# | |
# refer to | |
# https://pymodbus.readthedocs.io/en/latest/source/example/synchronous_client.html | |
# https://pymodbus.readthedocs.io/en/latest/source/example/synchronous_client_ext.html | |
# | |
# pip install pymodbus (not update this into requirement.txt) | |
# | |
# this program is only test for Modbus RTU | |
# this is working as a Modbus RTU Master and then everytime write/read holdregs in a Slave | |
# check the status of slave device | |
from pymodbus.client.sync import ModbusSerialClient | |
from pymodbus.constants import Endian # Endian and World | |
from pymodbus.payload import BinaryPayloadDecoder # decode binaries when read datas from Modbus-RTU | |
from threading import Timer | |
import time | |
import logging | |
import sys | |
from optparse import OptionParser | |
#from enum import IntEnum | |
from pymodbus.payload import BinaryPayloadBuilder # encode binaries when write datas into Modbus-RTU | |
from os import path, stat, SEEK_END | |
from struct import pack | |
import struct | |
# for checking speed | |
## only option (no need) | |
#from tqdm import tqdm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment