Quantcast

using usb_bulk_write (or read)

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

using usb_bulk_write (or read)

jack craig
Hi folks,

I need to use the usb_bulk_read/write to write data to / from a device using the libusb 0.1 library.

i use this to scan the bus for my device, ...

   for (usb_bus = usb_busses; usb_bus; usb_bus = usb_bus->next) {
       for (dev = usb_bus->devices; dev; dev = dev->next) {
          if ((dev->descriptor.idVendor == VID) &&
              (dev->descriptor.idProduct == PID))
             return dev;
        }
   }

now i need to write/read bytes, i find the sample, ...
send_status=usb_bulk_write(xsv_handle,4,&send_data,1,500)
printf("TX stat=%d\n",send_status);
	
usb_bulk_read(xsv_handle,3,&receive_data,1,500);	
printf("RX stat=%d -> RX char=%d\n",send_status,receive_data);

my question is, where do the endpoint values come from?

tia, jackc...


-- 
   jack craig
      [hidden email]
         831-684-1375 (Office)
            831-596-6924 (cell)
               IM: jackcraigaptos (AIM)

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Libusb-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: using usb_bulk_write (or read)

Tim Roberts
jack craig wrote:

> Hi folks,
>
> I need to use the usb_bulk_read/write to write data to / from a device
> using the libusb 0.1 library.
>
> i use this to scan the bus for my device, ...
>
>    for (usb_bus = usb_busses; usb_bus; usb_bus = usb_bus->next) {
>        for (dev = usb_bus->devices; dev; dev = dev->next) {
>           if ((dev->descriptor.idVendor == VID) &&
>               (dev->descriptor.idProduct == PID))
>              return dev;
>         }
>    }
>
> now i need to write/read bytes, i find the sample, ...
> send_status=usb_bulk_write(xsv_handle,*4,*&send_data,1,500)
> printf("TX stat=%d\n",send_status);
>
> usb_bulk_read(xsv_handle,*3,*&receive_data,1,500);
> printf("RX stat=%d -> RX char=%d\n",send_status,receive_data);
> *
> my question is, where do the endpoint values come from?*
>  

You have to KNOW that.  Each device defines its own endpoints and
endpoint numbers.  You are essentially writing a device driver here; it
is your responsibility, as the driver writer, to understand how your
device works.  Part of that responsibility includes knowing how your
endpoints are configured: which ones are input, which ones are output,
which ones serve which functions, what data format is expected, and so on.

A more or less "generic" libusb application can go read the
configuration descriptor to figure out which endpoints exist for this
device, but you still need to know something about the device.  If there
are 4 input endpoints and 2 output endpoints, which ones do the things
you need to do?

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Libusb-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: using usb_bulk_write (or read)

jack craig
Tim Roberts wrote:

> jack craig wrote:
>  
> You have to KNOW that.  Each device defines its own endpoints and
> endpoint numbers.  You are essentially writing a device driver here; it
> is your responsibility, as the driver writer, to understand how your
> device works.  Part of that responsibility includes knowing how your
> endpoints are configured: which ones are input, which ones are output,
> which ones serve which functions, what data format is expected, and so on.
>
> A more or less "generic" libusb application can go read the
> configuration descriptor to figure out which endpoints exist for this
> device, but you still need to know something about the device.  If there
> are 4 input endpoints and 2 output endpoints, which ones do the things
> you need to do?
>
>  
great feedback, lets take this a step further.

i use usbview to examine my usb 'widget' where it reports 2 end points,
81=out, 02=in, both are type int.

while libusb 1.0 has a usb_write_interrupt, 0.1 doesnt appear to,
the tutorial for libusb 0.1 i am reading speaks of only
usb_bulk_write,usb_bulk_read,usb_control_msg.

can i break the rules and use the bulk write/read ?

tia, jackc...

--
   jack craig
      [hidden email]
         831-684-1375 (Office)
            831-596-6924 (cell)
               IM: jackcraigaptos (AIM)

_________________________________
This email has been ClamScanned !
     www.LinuxLightHouse.com

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Libusb-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: using usb_bulk_write (or read)

Alan Stern
On Tue, 26 May 2009, jack craig wrote:

> great feedback, lets take this a step further.
>
> i use usbview to examine my usb 'widget' where it reports 2 end points,
> 81=out, 02=in, both are type int.
>
> while libusb 1.0 has a usb_write_interrupt, 0.1 doesnt appear to,
> the tutorial for libusb 0.1 i am reading speaks of only
> usb_bulk_write,usb_bulk_read,usb_control_msg.
>
> can i break the rules and use the bulk write/read ?

Yes, you can.

Alan Stern


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Libusb-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: using usb_bulk_write (or read)

Tim Roberts
In reply to this post by jack craig
jack craig wrote:
> i use usbview to examine my usb 'widget' where it reports 2 end points,
> 81=out, 02=in, both are type int.
>  

I think you have those backwards.  0x81 would be an IN pipe, and 0x02
would be an OUT pipe.

> while libusb 1.0 has a usb_write_interrupt, 0.1 doesnt appear to,
> the tutorial for libusb 0.1 i am reading speaks of only
> usb_bulk_write,usb_bulk_read,usb_control_msg.
>
> can i break the rules and use the bulk write/read ?
>  

Bulk transfers and interrupt transfers are identical in every respect.
The only differences between the two are in the way transfers are
scheduled by the host controller.

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Libusb-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: using usb_bulk_write (or read)

jack craig
In reply to this post by Alan Stern
Alan Stern wrote:
On Tue, 26 May 2009, jack craig wrote:

  
great feedback, lets take this a step further.

i use usbview to examine my usb 'widget' where it reports 2 end points, 
81=out, 02=in, both are type int.

while libusb 1.0 has a usb_write_interrupt, 0.1 doesnt appear to,
the tutorial for libusb 0.1 i am reading speaks of only 
usb_bulk_write,usb_bulk_read,usb_control_msg.

can i break the rules and use the bulk write/read ?
    

Yes, you can.

Alan Stern

_________________________________
This email has been ClamScanned !
     www.LinuxLightHouse.com
  
Sweet! thx very much Alan, ...

-- 
   jack craig
      [hidden email]
         831-684-1375 (Office)
            831-596-6924 (cell)
               IM: jackcraigaptos (AIM)

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Libusb-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: using usb_bulk_write (or read)

jack craig
In reply to this post by Tim Roberts
Tim Roberts wrote:
jack craig wrote:
  
  
      

I think you have those backwards. 0x81 would be an IN pipe, and 0x02
would be an OUT pipe.

while libusb 1.0 has a usb_write_interrupt, 0.1 doesnt appear to,
the tutorial for libusb 0.1 i am reading speaks of only 
usb_bulk_write,usb_bulk_read,usb_control_msg.

can i break the rules and use the bulk write/read ?
  
      

Bulk transfers and interrupt transfers are identical in every respect.
The only differences between the two are in the way transfers are
scheduled by the host controller.

i use usbview to examine my usb 'widget' where it reports 2 end points, 
81=out, 02=in, both are type int.
    

do i also have the sense of them backwards?

that is, i assume i write to the 0x81 and read from the 0x2, true?

also, to get debug for failed calls,

i export LIBUSB_DEBUG=3  also true?

thx,jackc...

-- 
   jack craig
      [hidden email]
         831-684-1375 (Office)
            831-596-6924 (cell)
               IM: jackcraigaptos (AIM)

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Libusb-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: using usb_bulk_write (or read)

Tim Roberts
jack craig wrote:
> Tim Roberts wrote:
>>>
>>> i use usbview to examine my usb 'widget' where it reports 2 end points,
>>> 81=out, 02=in, both are type int.
>>>    
>
> do i also have the sense of them backwards?
>
> that is, i assume i write to the 0x81 and read from the 0x2, true?

False.  Bit 7 of the endpoint number is set for an "IN" endpoint, and
clear for an "OUT" endpoint.  IN and OUT are from the point of view of
the host, so you READ from the IN endpoint 0x81, and WRITE to the OUT
endpoint 0x02.


> also, to get debug for failed calls,
>
> i export LIBUSB_DEBUG=3  also true?

Yes, although it is possible to compile libusb with a flag that disables
the debug logging altogether.

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Libusb-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-devel
Loading...