Deassign pins af before assigning. Make uart.any() return the correct value everytime, this requires interrupts to be always enabled.