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

ModbusSerialClient with RTU mothod doesn't read register #11

Open
zxpatric opened this issue Aug 25, 2017 · 0 comments
Open

ModbusSerialClient with RTU mothod doesn't read register #11

zxpatric opened this issue Aug 25, 2017 · 0 comments

Comments

@zxpatric
Copy link

zxpatric commented Aug 25, 2017

Using Code:
import pymodbus3.client.sync as pcs

client = pcs.ModbusSerialClient(method='rtu', port='COM15', parity='E', )
logging.debug(client.connect());
result = client.read_holding_registers(5302, unit=1)
logging.debug(result);

Got the console result:

DEBUG:root:True
DEBUG:pymodbus3.transaction:Running transaction 1
DEBUG:pymodbus3.transaction:getting transaction 1
DEBUG:root:None

Using the pyserial library directly and I got the register reading well.

    self.ser.baudrate = 19200
    self.ser.parity = serial.PARITY_EVEN
    self.ser.stopbits = serial.STOPBITS_ONE
    self.ser.xonxoff = 0
    self.ser.rtscts = 0
    self.ser.dsrdtr = 0

The result we received is:

DEBUG:root:b'\x01\x03\x02x\4B\x00\x8e\xb4'

Debug further into the function handle_message_framing,

when ReadingHeader, the framer only receive 1 bit since size = self.framer.header_size - len(self.framer.buffer). size equals to 1 with empty self.framer.buffer and self.framer.header_size equaling to 1. The check_frame() function afterwards actually failed to populate the header.

When ReadingContent, since it didn't read the header right, it also only reads 1 bit.

When FramerState.CompleteFrame, there is no data to add to the frame and failed out.

So, I am just wondering if it is because I missed some settings so the communication to the register appears to be right but the response parsing turns out to be wrong?

Thanks.

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