Working ASM for serial port communication