Implement common logic for send/receive UART