minimalmodbus: Checksum error in rtu mode

Hi,

I’ve got an error when I try to select some bits or registers from a modbus slave.

#!/usr/bin/env python3

import serial
import minimalmodbus
from time import sleep

client1 = minimalmodbus.Instrument('/dev/ttyAMA0', 10, debug=True)  # port name, slave address (in decimal)
client1.serial.baudrate = 19200
client1.serial.bytesize = 8
client1.serial.parity   = serial.PARITY_EVEN
client1.serial.stopbits = 1
client1.serial.timeout  = 0.1
client1.mode = minimalmodbus.MODE_RTU

res = client1.read_register(1001, 1, 4)
print (res)

The Response

MinimalModbus debug mode. Create serial port /dev/ttyAMA0
MinimalModbus debug mode. Will write to instrument (expecting 7 bytes back): 0A 04 03 E9 00 01 E1 01 (8 bytes)
MinimalModbus debug mode. Clearing serial buffers for port /dev/ttyAMA0
MinimalModbus debug mode. No sleep required before write. Time since previous read: 1755610178.72 ms, minimum silent period: 2.01 ms.
MinimalModbus debug mode. Response from instrument: FB F8 7F 00 (4 bytes), roundtrip time: 0.1 ms. Timeout for reading: 100.0 ms.

Traceback (most recent call last):
  File "minimal.py", line 42, in <module>
    res = client1.read_register(1001, 1, 4)
  File "/usr/local/lib/python3.7/dist-packages/minimalmodbus.py", line 486, in read_register
    payloadformat=_Payloadformat.REGISTER,
  File "/usr/local/lib/python3.7/dist-packages/minimalmodbus.py", line 1245, in _generic_command
    payload_from_slave = self._perform_command(functioncode, payload_to_slave)
  File "/usr/local/lib/python3.7/dist-packages/minimalmodbus.py", line 1330, in _perform_command
    response, self.address, self.mode, functioncode
  File "/usr/local/lib/python3.7/dist-packages/minimalmodbus.py", line 1867, in _extract_payload
    raise InvalidResponseError(text)
minimalmodbus.InvalidResponseError: Checksum error in rtu mode: '\x7f\x00' instead of 'C\x02' . The response is: 'ûø\x7f\x00' (plain response: 'ûø\x7f\x00')

Do you have any recomendations for analyzing the problem?

About this issue

Most upvoted comments

@Coder73-avi As mentioned several times, the problem is outside of the minimalmodbus library. If you need help, read the documentation first (Serial communication, Troubleshooting). Make sure you check and fix everything mentioned here. Make sure you have a good RS-485 transceiver solution (also mentioned in the documentation).

If you have tried everything in the documentation and it still does not work, please describe your situation in detail.

  • Your hardware
  • Your RS-485 transceiver
  • Your wiring and the topology of your entire system (data connections, power connections)
  • The device you are trying to communicate with

You should first disable services using the /dev/ttyAMA0.

E.g.

  • diable hciuart service
  • add dtoverlay=disable-bt in config.txt

please search yourself. It is out of the scope of this library.