implelent the serial port function