Why I am not able to read this file. I tried reading this file with cat as :
cat /dev/video0
But it says
cat: /dev/video0 : invalid arguments
Similarly, if I try to use dd as :
dd if=/dev/video0 ~/vid
It still is not able to read it.
Note that video0 is the device file for my webcam.
In such cases, one way to find out more is to run the command in strace
strace cat /dev/video0
which will show more details of the point of failure:
....
open("/dev/video0", O_RDONLY) = 3
fstat(3, {st_mode=S_IFCHR|0660, st_rdev=makedev(81, 0), ...}) = 0
fadvise64(3, 0, 0, POSIX_FADV_SEQUENTIAL) = 0
read(3, 0x2379000, 65536) = -1 EINVAL (Invalid argument)
....
which in my case seems to be saying that my /dev/video0 device does not support the required operation: so in this case, 'cat' is trying to read 64k bytes from the device.
However, I found that using nc (netcat) instead of cat did work for this purpose:
nc -l 1234 </dev/video0
With a corresponding:
nc 127.0.0.1 1234 | mplayer tv://device=/dev/stdin
to display locally; an SSH tunnel port would also work here.
I use:
dd if=/dev/video0 of=~/movie.mpg
Then
vlc movie.mpg
But I'm using a PVRUSB2 mpg encoder/decoder as the source.
In your dd invocation you might consider a redirect, ">", of using the "of" construct.
I think that the show function for the device node "video0" you created in your driver might be wrong.
Give an example in below.
static DEVICE_ATTR(video0, S_IRUGO|S_IWUSR|S_IWGRP|S_IWOTH, video0_show, video0_store);
static ssize_t video0_show(struct device *dev, struct device_attribute *attr, char *buf);
static ssize_t video0_store(struct device *dev, struct device_attribute *attr, char *buf, size_t count);
When you cat the device node "video0" at runtime, it calls the "video0_show" function to print something. The error message "cat: /dev/video0 : invalid arguments" means that the arguments for the video0_show function is wrong. You should debug the driver.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With