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.

Parameters:
porta GPPort
datathe data to write to the port
sizethe 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).

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

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

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

{
      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);
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index