LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-15-2008, 04:41 AM   #1
zali
Member
 
Registered: Sep 2005
Distribution: Suse
Posts: 56

Rep: Reputation: 15
Again problem with libhid


Hi,
I have a problem with libhid, I asked it in a thread but I did not receive any solution, so I'm writing about my problem again,
The problem is basically with opening a hid device,when I run the program, once it runs truly, but the next time the program can not open the device, it means once open successfully and the next time it fails, again the next time success and the time after that fail , ...

My code is as below code:

>>>
int main(void)
{
HIDInterface* hid;
hid_return ret;

HIDInterfaceMatcher matcher = { 0x0925,0x1234, NULL, NULL, 0 };

/* see include/debug.h for possible values */
hid_set_debug(HID_DEBUG_ALL);
hid_set_debug_stream(stderr);
/* passed directly to libusb */
hid_set_usb_debug(0);

ret = hid_init();
if (ret != HID_RET_SUCCESS) {
fprintf(stderr, "hid_init failed with return code %d\n", ret);
return 1;
}

hid = hid_new_HIDInterface();
if (hid == 0) {
fprintf(stderr, "hid_new_HIDInterface() failed, out of memory?\n");
return 1;
}

ret = hid_force_open(hid, 0, &matcher, 2,0);
if (ret != HID_RET_SUCCESS) {
fprintf(stderr, "hid_force_open failed with return code %d\n", ret);
return 1;
}
else{
printf("Open Device successfully\n");
}

ret = hid_close(hid);
if (ret != HID_RET_SUCCESS) {
fprintf(stderr, "hid_close failed with return code %d\n", ret);
return 1;
}

hid_delete_HIDInterface(&hid);

ret = hid_cleanup();
if (ret != HID_RET_SUCCESS) {
fprintf(stderr, "hid_cleanup failed with return code %d\n", ret);
return 1;
}

return 0;
}

<<<

Please help me whit it.
Thanx
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with Libhid ( delay occur ) zali Programming 1 07-03-2008 04:43 AM
Is there any way to program for a usb hiddevice except libhid? zali Programming 0 07-02-2008 06:55 AM
problem with LibHid zali Programming 2 07-02-2008 05:21 AM
perl problem? apache problem? cgi problem? WorldBuilder Linux - Software 1 09-17-2003 07:45 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration