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

int gp_port_read ( GPPort port,
char *  data,
int  size 
)

Read data from port.

Parameters:
porta GPPort
dataa pointer to an allocated buffer
sizethe number of bytes that should be read

Reads a specified number of bytes from the port into the supplied buffer. It returns the number of bytes read or a negative error code.

Returns:
a gphoto2 error code or the amount of data read

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

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

{
        int retval;

      gp_log (GP_LOG_DEBUG, "gphoto2-port", _("Reading %i=0x%x bytes from port..."),
            size, size);

      CHECK_NULL (port);
      CHECK_INIT (port);

      /* Check if we read as many bytes as expected */
      CHECK_SUPP (port, "read", port->pc->ops->read);
      retval = port->pc->ops->read (port, data, size);
      CHECK_RESULT (retval);
      if (retval != size)
            gp_log (GP_LOG_DEBUG, "gphoto2-port", _("Could only read %i "
                  "out of %i byte(s)"), retval, size);

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

      return (retval);
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index