David J. Topper wrote:
I can capture frames just fine, but can't seem to close the device
and reopen it. (...) cam = open("/dev/video", O_RDONLY ); if (cam<0)
{ printf("ERROR: THERE IS NO CAMERA CONECTED\n"); }
You should use perror() instead of printf(), i.e. look at the content
of the errno variable, it will contain a hint what's the problem (e.g.
EBUSY if the device is still open). You might also want to check the
return code of close(), possibly you've already overwritten the file
handle, then you'd see a EBADF. Generally it should be no problem to
close and re-open a video device.
BTW I've been looking for a way to stop capturing *without* closing
the device. When using v4l2 streams I can use the STREAMOFF ioctl,
however there seems to be no such possibility when capturing via
read()
My problem is that I'd like to use the S_FMT ioctl, but it always
fails with EBUSY if I've done any read()s before. Closing and
re-opening the device works fine, but I'd prefer a solution with
less overhead. Ideas, anyone? (I'm currently developing for
the libzvbi library, so I'd prefer to find a clean and portable
solution for drivers which do not support capturing via streams.)
bye,
-tom