exception catch for serial port write