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

Why is the read_coils return value not a ReadCoilsResponse object? #1478

Closed
lui305 opened this issue Apr 8, 2023 · 1 comment · Fixed by #1479
Closed

Why is the read_coils return value not a ReadCoilsResponse object? #1478

lui305 opened this issue Apr 8, 2023 · 1 comment · Fixed by #1479

Comments

@lui305
Copy link

lui305 commented Apr 8, 2023

Versions

  • Python:3.9.13
  • OS:windows
  • Pymodbus:3.2.2

Pymodbus Specific

  • Server: tcp
  • Client: tcp

Description

Hi!
When I am alone read_coils function, the return value for “ReadDiscreteInputsResponse (24)”, when I use write_coil functions first, then use read_coils function, Its return value changes to “WriteCoilResponse(100) => True”. Shouldn't the return value of the read_coils function be the ReadCoilsResponse object?

Code and Logs

code one:
###################
from pymodbus.client import ModbusTcpClient
# 连接到Modbus服务器
client = ModbusTcpClient('169.254.94.2', port=502)
client.connect()
# client.write_coil(100,True,1)
a=client.read_coils(100,1)
print(a)
# close the connection
client.close()
#################
print (a) is " ReadDiscreteInputsResponse (24)"
#################

code two:
###################
from pymodbus.client import ModbusTcpClient
# 连接到Modbus服务器
client = ModbusTcpClient('169.254.94.2', port=502)
client.connect()
client.write_coil(100,True,1)
a=client.read_coils(100,1)
print(a)
# close the connection
client.close()
#################
print (a) is " WriteCoilResponse(100) => True"
#################
@janiversen
Copy link
Collaborator

I am not sure what problem you have, but pymodbus works as expected, please see the example I added.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants