Added logic to trap and recover from serial IO errors