Small serial port refactoring