Logo Search packages:      
Sourcecode: libgphoto2 version File versions  Download package

int gp_port_write ( GPPort port,
const char *  data,
int  size 

Writes a specified amount of data to a port.

port a GPPort
data the data to write to the port
size the number of bytes to write to the port
Writes data to the port. On non-serial ports the amount of data written is returned (and not just GP_OK).

a negative gphoto2 error code or the amount of data written.

Definition at line 342 of file gphoto2-port.c.

References CHECK_NULL, CHECK_RESULT, gp_log(), gp_log_data(), GP_LOG_DEBUG, GP_PORT_SERIAL, _GPPortPrivateCore::ops, _GPPort::pc, _GPPort::type, and _GPPortOperations::write.

      int retval;

      gp_log (GP_LOG_DEBUG, "gphoto2-port", _("Writing %i=0x%x byte(s) "
            "to port..."), size, size);

      CHECK_NULL (port && data);
      CHECK_INIT (port);

      gp_log_data ("gphoto2-port", data, size);

      /* Check if we wrote all bytes */
      CHECK_SUPP (port, "write", port->pc->ops->write);
      retval = port->pc->ops->write (port, data, size);
      CHECK_RESULT (retval);
      if ((port->type != GP_PORT_SERIAL) && (retval != size))
            gp_log (GP_LOG_DEBUG, "gphoto2-port", _("Could only write %i "
                  "out of %i byte(s)"), retval, size);

      return (retval);

Generated by  Doxygen 1.6.0   Back to index