NeethuVP
Member level 2
I have a modbus schneider connected to a orangepi via uart..using RS485 converter.. i need to read the schneider data through uart.. how can i read the registers of modbus(3901) via uart? please help me
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
import serial
from pyA20.gpio import gpio
from pyA20.gpio import port
from time import sleep
gpio.init()
gpio.setcfg(port.PA7, gpio.OUTPUT)
ser = serial.Serial(
port='/dev/ttyS3',
baudrate = 9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
gpio.output(port.PA7, gpio.HIGH)
ByteStringToSend = "\x01\x03\x0F\x48\x00\x02\x47\x09"
ser.write(ByteStringToSend)
sleep(0.5)
gpio.output(port.PA7, gpio.LOW)
ReceivedData = ""
while (ReceivedData == ""):
RecievedData = ser.readline();
print RecievedData.encode('hex')
ser.close()
Please use the correct terminology. Do you mean "device address"?the slave ID is 1
But you know it is 8E1, Which means EVEN parity.parity=serial.PARITY_NONE,
I first thought this means: it is working nowi can read from the Schneider through RS485 USB converter
pyA20, https://pypi.org/project/pyA20/ is for Olimex board https://www.olimex.com/Products/OLinuXino/A20/A20-OLinuXino-MICRO/open-source-hardwarefrom pyA20.gpio import gpio
* Use a scope to see the signals of the Modbus with using the (working) USB converterSorry Klaus, i didn't get you .. what's mean by the traffic on the bus? how to compare it?
Reviewing the code in post #3, you are blocking the receiver for 0.5 seconds, so you surely can't receive the response within the specified MODBUS timeout. A sufficient condition to make the code fail.
I'm not sure how ser.write() is connected to the low level UART driver, if it's performing a blocking direct or buffered UART write.
i commented the sleep and now i'm able to get response
Thank you FvM