Add I/O flushing & error return to serial_reset(...)
Fix non-standard use of const