Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poor quality of communications #188

Open
SoUtHeaST41 opened this issue Mar 5, 2024 · 0 comments
Open

Poor quality of communications #188

SoUtHeaST41 opened this issue Mar 5, 2024 · 0 comments

Comments

@SoUtHeaST41
Copy link

SoUtHeaST41 commented Mar 5, 2024

I am using modbus tk to simulate a slave on a raspberry pi with the following code:
`import modbus_tk
import modbus_tk.defines as cst
from modbus_tk import modbus_rtu
import serial
import time

PORT = "/dev/ttyUSB0"

def main():
"""main"""
#Create the server
server = modbus_rtu.RtuServer(serial.Serial(PORT,baudrate=9600,bytesize=8,parity='N', stopbits=1))
t = 32

try:
    server.start()

    slave = server.add_slave(8)

    slave.add_block('0', cst.HOLDING_REGISTERS, 0, 10)
 
    slave.set_values('0', 0, [t, 87, 255, 0, 1, 0, 1, 1,22])
  
    while True:
        values = slave.get_values('0', 0, 10)
        
        print('values read: %s\r\n' % (str(values)))
        print("wait for a while...")
        time.sleep(1)
            

finally:
    server.stop()

if name == "main":
main()
Use modbus poll at the PC to simulate the master reading and writing to the slave registers.
However, the quality of communications has been poor, with a ratio of successful communications to communications timeouts of about 2 to 1.
微信图片_20240305202403
Please point out my problem or include it in the next version of the upgrade!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant