implement serialport function