Logo Search packages:      
Sourcecode: libdc1394-22 version File versions  Download package

dc1394error_t dc1394_avt_write_gpdata ( dc1394camera_t camera,
unsigned char *  buf,
uint32_t  size 
)

Write size number of bytes to GPData buffer

Definition at line 1427 of file avt.c.

{
    uint32_t gpdata_bufsize, gpdata_numquads;
    uint32_t nQuadWriteSize, newBufferSize;
    uint32_t i, index = 0, nextIndex;
    uint32_t *buf_local;
    dc1394bool_t finish = DC1394_FALSE;
    dc1394error_t err;

    /* determine gpdata_bufsize */
    err = dc1394_avt_get_gpdata_info(camera, &gpdata_bufsize);
    DC1394_ERR_RTN(err,"Could not get AVT GPData info");

    /* calculate the number of quadlets in the gpdata buffer */
    gpdata_numquads = gpdata_bufsize / 4;
    if ((gpdata_bufsize % 4) != 0)
        gpdata_numquads++;

    /* allocate memory for the write buffer */
    buf_local = malloc(gpdata_numquads * sizeof(uint32_t));
    if (buf_local == NULL)
        return DC1394_FAILURE;

    do {
        gpdata_io_common(buf_local, gpdata_numquads, &nextIndex, index, size, &newBufferSize, &nQuadWriteSize, &finish);

        /* copy block-contents to buf_local */
        for (i = 0; i < nQuadWriteSize; i++)
            memcpy(&buf_local[i], buf + index + (i * 4), sizeof(uint32_t));

        /* write block */
        err = dc1394_set_adv_control_registers(camera, REG_CAMERA_AVT_GPDATA_BUFFER,
                                               buf_local, nQuadWriteSize);
        if (err != DC1394_SUCCESS) {
            free(buf_local);
            return DC1394_FAILURE;
        }

        index += (nQuadWriteSize * 4);

        /* loop until all bytes are read */
    } while (!finish);

    free(buf_local);
    return DC1394_SUCCESS;
}


Generated by  Doxygen 1.6.0   Back to index