Refactored serial port listener