0

I cannot print anything on pi terminal Please help

from pymodbus.client.sync import ModbusSerialClient
import serial.rs485
import time
import logging
import pprint
pp= pprint.PrettyPrinter(indent=4)
FORMAT = ('%(asctime)-15s %(threadName)-15s'
' %(levelname)-8s %(module)-15s:%(lineno)-8s %(message)s')
logging.basicConfig(format=FORMAT)
log = logging.getLogger()
log.setLevel(logging.DEBUG)
ser = serial.rs485.RS485(port='/dev/serial0', baudrate=19200)
ser.rs485_mode = serial.rs485.RS485Settings(rts_level_for_tx=False,
                                            rts_level_for_rx=True,
                                            delay_before_tx=0.0,
                                            delay_before_rx=-0.0)

client = ModbusSerialClient(method='rtu')
client.socket = ser
client.connect()
print("Connected")

response = client.read_input_registers(address=6, count=2, unit=0x01)


print("Temperature at 0x06: ",response.registers)

client.close()

OUTPUT

pi@raspberrypi:~/ewc_app $ python3 modbus.py
Connected
2022-02-16 17:05:06,928 MainThread      DEBUG    transaction    :140      Current transaction state - IDLE
2022-02-16 17:05:06,928 MainThread      DEBUG    transaction    :145      Running transaction 1
2022-02-16 17:05:06,928 MainThread      DEBUG    transaction    :273      SEND: 0x1 0x4 0x0 0x6 0x0 0x2 0x91 0xca
2022-02-16 17:05:06,929 MainThread      DEBUG    sync           :76       New Transaction state 'SENDING'
Pranav Hosangadi
  • 23,755
  • 7
  • 44
  • 70
  • [Please do not upload images of code/errors when asking a question.](//meta.stackoverflow.com/q/285551) Include it as a [formatted code block](/help/formatting) instead of an image. [Why do we hate screenshots so much?](//meta.stackoverflow.com/q/303812/) – Pranav Hosangadi Feb 16 '22 at 17:16
  • Please also take the [tour], and read [what's on-topic here](/help/on-topic), [ask], and the [question checklist](//meta.stackoverflow.com/q/260648/843953). It's not enough to simply dump your code here. You need to tell us what went wrong with it and actually _ask a question_. Welcome to SO – Pranav Hosangadi Feb 16 '22 at 17:17
  • @PranavHosangadi Can you check it now? – Kaiffee Bains Feb 16 '22 at 17:23

0 Answers0