LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   accessing device driver from C application (https://www.linuxquestions.org/questions/linux-hardware-18/accessing-device-driver-from-c-application-886289/)

baraq 06-14-2011 10:43 AM

accessing device driver from C application
 
Hi,

I wrote device driver to USB device, I can see it is alive and sending the data that I set it to send from the shell
Code:

cat /dev/myDev
How can I read from the device using C code?
I've tried to open it as a file and read it's content to buffer but noting returns..

Code:

char bufferin[500];
FILE* myDev = fopen("/dev/myDev", "r+");

size = fread(bufferin, 500, 500, myDev);

Thanks

baraq 06-14-2011 03:01 PM

anyone?

baraq 06-15-2011 02:47 AM

OK
Found a solution

Code:

int myDevFd = open("/dev/myDev", O_RDWR);

size = read(myDevFd, bufferin, 500);



All times are GMT -5. The time now is 04:00 AM.