0

Followed this thread on enabling the serial console on the Raspberry Pi 3B.

Checked the functionality using this code:

dmesg | grep tty

Which produced these results:

...
console [tty1] enabled
...
console [ttyAMA0] enabled

However, when I tried to use pymodbus, I couldn't even connect to the client. Used this code:

import pymodbus
from pymodbus.client.sync import ModbusSerialClient as ModbusSerialClient
from pymodbus.register_read_message import ReadInputRegistersResponse

client = ModbusSerialClient(method='rtu', port='/dev/ttyAMA0', stopbits=1, bytesize=8, parity='N', baudrate='9600', timeout=0.3)

connection = client.connect()

My Raspberry Pi 3B is not communicating with the energy meter (53U-1211-AD4/H), used the energy meter's T1, T2, T4 (GND) for the modbus connection. Used the RPI's UART pins 8 & 10 (GPIO14 & GPIO15).

Error:

...
self socket interCharTimeout = self.inter_char_timeout
...
AttributeError: 'NoneTyoe' object has no attribute 'interCharTimeout'

Anyone used pymodbus before? I've been on this for days, followed several threads on enabling the serial port to no avail.

Ghanima
  • 15,578
  • 15
  • 58
  • 113
cknz
  • 21
  • 4
  • I realise this is an old question but since it has been bumped... if you want to use the built-in UART for Modbus then surely you need to **disable** the serial console? – nekomatic Oct 07 '19 at 15:08

1 Answers1

0

You appear to be using an older OS - unspecified. TtyAMA0 is connected to Bluetooth - a current OS would use serial0

Milliways
  • 54,718
  • 26
  • 92
  • 182