LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 11-06-2008, 06:15 AM   #1
bonrocaille
LQ Newbie
 
Registered: Nov 2008
Posts: 1

Rep: Reputation: 0
libusb HELP: 'usb_bulk_read: Resource temporarily unavailable'


asd

Last edited by bonrocaille; 01-05-2010 at 04:42 PM.
 
Old 11-26-2008, 11:13 AM   #2
byatin
LQ Newbie
 
Registered: Nov 2008
Posts: 1

Rep: Reputation: 0
problem with write and read

hi , i am new to this forum and i am using the same code as yours, when i run this code the output comes as:-


Found tikitag!
usb: open
Now Program RUN

usb_bulk_write: Operation not permitted
xchange: Illegal seek
closing


I have disabled the functions usb_claim_interface,usb_clear_halt,usb_detach_kernel_driver,
usb_set_configuration,As they are giving me the errors,

Also Can you please tell me what to fill in the ep field of write and read functions.


Also Can you please tell me is there any doc available for the libusb ,and if so can u please send me the link.


My email id is byatin@gmail.com


/************Code*************************?



#include <usb.h>
#include <stdio.h>

/*
* ** tiki_get_dev()
* ** find the first tiki device connected
* */
struct usb_device *tiki_get_dev()
{
struct usb_bus *busses, *bus;
struct usb_device *dev;
usb_init();
usb_find_busses();
usb_find_devices();
busses = usb_get_busses();
for (bus = busses; bus; bus = bus->next)
{
for (dev = bus->devices; dev; dev = dev->next)
{
if (dev->descriptor.idVendor == 0x0d49 && /* ACS */
dev->descriptor.idProduct == 0x7450) /* Tiki (ACR122) */
{
printf("Found tikitag!\n");
break;
}
printf("Searching...\n");
}
if (dev)
break;
}
return(dev);
}

/*
* ** tiki_xchange(udp, *outp, out_len, *inp, in_len)
* ** send a command to the reader and gets the answer
* ** returns 0 if all goes well; -1 if not
* */

#define TIMEOUT 20*1000 /*HZ*/
int tiki_xchange(struct usb_dev_handle* udp, u_char *outp, int out_len, u_char *inp,
int in_len)
{
int bytes_sent;
int bytes_recv;

if ((bytes_sent=usb_bulk_write(udp, 0x02 /* EP_OUT */, (char *)outp, out_len,
TIMEOUT)) < 0)
{
perror("usb_bulk_write");
return(-1);
}

printf("bytes sent: %d\n\n", bytes_sent);

int i;
if ((bytes_recv=usb_bulk_read(udp, 0x82 /* EP_IN */, (char *)inp, in_len,
TIMEOUT)) < 0)
{
perror("usb_bulk_read");
return(-1);
}

printf("bytes recv: %d\n", bytes_recv);

for (i=0;i<bytes_recv;i++)
{
printf("input[i]: %d\n", inp[i]);
}

printf("\n");
/*
* if (inp[1])
{
printf("inp[1] error\n");
return(-1); // bad status -- should set errno
}
*/
return(0);
}

/*
* **Application
* */
int main()
{
struct usb_device *dev;
struct usb_dev_handle* tiki;

static u_char outp[] = {0xFF, 0x00, 0x40, 0xD0, 0x04, 0x05, 0x05, 0x03, 0x01};
static u_char buf_in[128];

if ((dev = tiki_get_dev()) == NULL)
{
printf("Didn't Find tikitag reader...\n");
exit(-1);
}

if ((tiki = usb_open(dev)) == NULL)
{
printf("Stopped at USB Open");
perror("usb_open");
exit(-1);
}
printf("usb: open\n");

/*if ((usb_claim_interface(tiki, 0))<0)
{
perror("usb_claim_interface");
exit(-1);
}

if ((usb_clear_halt(tiki, 0x82))<0)
{
perror("usb_clear_halt");
exit(-1);
}

if ((usb_detach_kernel_driver_np(tiki, 0))<0)
{
perror("usb_detach_kernel_driver_np");
exit(-1);
}

if ((usb_set_configuration(tiki, 1))<0)
{
perror("usb_set_configuration");
exit(-1);
}*/

printf("Now Program RUN\n\n");

if (tiki_xchange(tiki, outp, sizeof(outp), buf_in, sizeof(buf_in)) < 0)
{
perror("xchange");
//exit(-1);
}

printf("closing\n");
if (usb_close(tiki) < 0)
{
perror("usb_close");
exit(-1);
}
exit(0);
}
 
  


Reply

Tags
driver, libusb, usb



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
fork: resource temporarily unavailable ??? str8edge Linux - General 3 06-21-2011 09:00 AM
vfork: resource temporarily unavailable verbose Linux - General 5 02-04-2007 04:17 AM
usb_bulk_read() - open error 11 Resource temporarily unavailable GSMD Programming 0 10-24-2006 01:07 AM
Siocsifflags: Resource Temporarily Unavailable camapa Linux - Networking 0 09-24-2005 07:58 PM
SIOCSIFFLAGS: Resource temporarily unavailable bleef Linux - Networking 2 05-14-2001 10:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 07:21 PM.

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