Added error handling to serial ports.