2

I have a python program that works fine with Raspberry Pi 3 and with an older Jessie version.

I've tested Jessie 4.4 version and I got the following error:

p1 = request1.registers

AttributeError: 'NoneType' object has no attribute 'registers'

The code is simple:

import pymodbus
import serial
import time
from pymodbus.pdu import ModbusRequest
from pymodbus.client.sync import ModbusSerialClient as ModbusClient 
from pymodbus.transaction import ModbusRtuFramer

client1 = ModbusClient(method = "rtu", port="/dev/ttyAMA0",stopbits = 1, bytesize = 8, parity = 'E', baudrate= 115200) connection = client1.connect() request1 = client1.read_holding_registers(0x500B,0x02,unit=1) p1 = request1.registers
print p1

The UART pins are in state ALT0:

  8  | 1 | ALT0 | TxD     | 15  | 14  |

10 | 1 | ALT0 | RxD | 16 | 15 |

The /boot/cmdline.txt file was modified also the serial interface was disabled.

Any idea what is happening?

Itzik
  • 21
  • 3

1 Answers1

2

In the Pi3 /dev/ttyAMA0 is connected to Bluetooth.

You should now (in all Pi) use /dev/serial0 which is the device on the GPIO pins.

There may be other issues (not least for some unfathomable reason the Foundation decided to turn serial port off by default).

See How-do-i-make-serial-work-on-the-raspberry-pi3

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • Hi, I've added to /boot/config.txt enable_uart=1, and ttyS0 was created but i also noticed that the serial interface was enabled. the Tx and Rx are now in ALT5 mode. after many tests i have the same issue: object has no attribute 'registers' – Itzik Jun 06 '16 at 21:26
  • I swear I just used a USB voice modem with /dev/ttyAMA0 using my Pi3 and Jessie Pixel and I got it to recognize AT commands - without turning off Bluetooth. Was that my imagination - or will both work concurrently without issues? – dbmitch Nov 10 '16 at 07:54