Proper statemachine for uart communication