Add serial_read()/serial_write() which have different implementations on MinGW/Windows. Add some more error code handling and documentation.