sorry, me again,
about the bad file descriptor,
in :
setpwc_bang
fd=-1; does not look right to me.
Maybe you could declare it as a global variable, and it does not need
to be a pointer;
After
fd = open(device, O_RDWR);
do not change its value.
good luck
oliver
oliver
Roman Haefeli wrote:
> hi
>
> i am still trying to find a way to overcome the
> 'agc-setting-is-reset-each-time-cam-is-accessed' problem. a friend of
> mine tried to help by writing a pd-object, that does send the 'restore'
> command to the driver, so that i can at least set the gain manually,
> when working with pd, just by restoring the nvram of the cam.
>
> however, it doesn't work yet. i am not a c coder myself and thus have no
> idea to fix it.
>
> i get the error:
>
> IDIOCPWCRUSER: Bad file descriptor
>
> this is the code of pd-object:
>
> ########################################################################
> #include <errno.h>
> #include <string.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <sys/ioctl.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> #include <unistd.h>
> #define _LINUX_TIME_H 1 /* to get things compile on kernel 2.6.x */
> #include <linux/videodev.h>
>
>
> #include "m_pd.h"
> #include "pwc-ioctl.h"
>
> char *device = "/dev/video1";
>
> static t_class *setpwc_class;
>
> typedef struct _setpwc {
> t_object x_obj;
> } t_setpwc;
>
> void check_device(int *fd)
> {
> if (*fd == -1)
> {
> /* open device */
> *fd = open(device, O_RDWR);
> if (*fd == -1)
> {
> post("Error while accessing device");
> // exit(1);
> }
> }
> }
>
> void restore_settings(int fd)
> {
> if (ioctl(fd, VIDIOCPWCRUSER) == -1)
> perror("VIDIOCPWCRUSER");
> }
>
> void setpwc_bang(t_setpwc *x)
> {
> int fd = -1;
> check_device(&fd);
> restore_settings(fd);
> }
>
> void *setpwc_new(void)
> {
> t_setpwc *x = (t_setpwc *)pd_new(setpwc_class);
>
> return (void *)x;
> }
>
> void setpwc_setup(void) {
> setpwc_class = class_new(gensym("setpwc"),
> (t_newmethod)setpwc_new,
> 0, sizeof(t_setpwc),
> CLASS_DEFAULT, 0);
> class_addbang(setpwc_class, setpwc_bang);
>
>
>
>
>
>
>
> ___________________________________________________________
> Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
> _______________________________________________
> pwc mailing list
>
> http://lists.saillard.org/mailman/listinfo/pwc
>
>
_______________________________________________
pwc mailing list
http://lists.saillard.org/mailman/listinfo/pwc
|