I am connecting PIC with Raspberry PI through a serial port. My max485 transmit and receive enable pin is controlled by gpio pin. My received data is printed successfully. But it is not performing the desired function.
while True:
GPIO.output(repin, False)
port.flushInput()
time.sleep(.oo5)
port.write(bytes(address))
time.sleep(.01)
GPIO.output(repin, Ture)
port.flushInput()
data=port.readline()
if data:
address=address+1
if data == "ok" :
print "reached"
print data
if not data:
print "no data"
when I am receiving OK. It prints "ok" but it didn't print "reached". And when data is not received it is printing a blank value instead of "no data".
There is nothing wrong in your code. If you write PIC program correctly then the problem is coming from the proper termination resistors of max485.connect twisted pair cable ground with proper resistance.