rv += ch
if ch == '\r' or ch == '':
    return rv
port = serial.Serial('/dev/ttyAMA0', baudrate=7200, timeout=2)
while True:
    rcv = readlineCR(port)
port.write('I typed: ' + repr(rcv))
print(rcv)
Sending serial communication from Raspberry pi