Hardik Shah | 29 Mar 2012 06:47

Reg: Return Response from Usb Device

Hi,

 

I am working on a code which requires communication of java code with usb device. For that I am using javax.usb api

 

I was successfully able to send vendor specific commands that control the usbDevice. Please find below snippet of code

 

byte bmRequestType =  UsbConst.REQUESTTYPE_DIRECTION_OUT | UsbConst.REQUESTTYPE_TYPE_CLASS | UsbConst.REQUESTTYPE_RECIPIENT_INTERFACE;

                                byte bRequest = 0x09;  

                                short wValue = 0x0300 

                                short wIndex = 0;            

                                byte[] buffer = {};// propertiary command to be send to usbDevice

                                UsbControlIrp usbControlIrp = usbDevice.createUsbControlIrp(bmRequestType, bRequest, wValue, wIndex);

                                usbControlIrp.setData(buffer);

                                usbDevice.syncSubmit(usbControlIrp);

 

However I come across a situation where I need to get some information back from usbDevice (i.e. I will send some command and device will return the some specific information). In other words, I need to  write some command to the device  and read response for the same. How can I achieve this..?.   A code snippet or  working example  will be helpful.

 

Please find endpoint information

 

                if (t == UsbConst.ENDPOINT_TYPE_INTERRUPT && ep.getDirection() == UsbConst.ENDPOINT_DIRECTION_IN

                                                                                && ep.getUsbEndpointDescriptor().bEndpointAddress() == SCHOMAKER_ENDPOINT_ADDR ) {

                                                                endptIn = ep;

                                                                System.out.println("DEBUG AbstractCardReader endpoint is selected " );

                                                                foundEp = true;

                                                                break;

 

Thanks

Shah

 

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
javax-usb-devel mailing list
javax-usb-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
Chuck Cook | 29 Mar 2012 13:18
Picon
Favicon

Re: Reg: Return Response from Usb Device


https://github.com/trygvis/javax-usb-libusb1

You may find something here.  I am not sure how up to date it is.


On 03/29/2012 12:47 AM, Hardik Shah wrote:

Hi,

 

I am working on a code which requires communication of java code with usb device. For that I am using javax.usb api

 

I was successfully able to send vendor specific commands that control the usbDevice. Please find below snippet of code

 

byte bmRequestType =  UsbConst.REQUESTTYPE_DIRECTION_OUT | UsbConst.REQUESTTYPE_TYPE_CLASS | UsbConst.REQUESTTYPE_RECIPIENT_INTERFACE;

                                byte bRequest = 0x09;  

                                short wValue = 0x0300 

                                short wIndex = 0;            

                                byte[] buffer = {};// propertiary command to be send to usbDevice

                                UsbControlIrp usbControlIrp = usbDevice.createUsbControlIrp(bmRequestType, bRequest, wValue, wIndex);

                                usbControlIrp.setData(buffer);

                                usbDevice.syncSubmit(usbControlIrp);

 

However I come across a situation where I need to get some information back from usbDevice (i.e. I will send some command and device will return the some specific information). In other words, I need to  write some command to the device  and read response for the same. How can I achieve this..?.   A code snippet or  working example  will be helpful.

 

Please find endpoint information

 

                if (t == UsbConst.ENDPOINT_TYPE_INTERRUPT && ep.getDirection() == UsbConst.ENDPOINT_DIRECTION_IN

                                                                                && ep.getUsbEndpointDescriptor().bEndpointAddress() == SCHOMAKER_ENDPOINT_ADDR ) {

                                                                endptIn = ep;

                                                                System.out.println("DEBUG AbstractCardReader endpoint is selected " );

                                                                foundEp = true;

                                                                break;

 

Thanks

Shah

 



------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure

_______________________________________________ javax-usb-devel mailing list javax-usb-devel <at> lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
javax-usb-devel mailing list
javax-usb-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
trygvis | 29 Mar 2012 13:34
Picon

Re: Reg: Return Response from Usb Device

On Thu, Mar 29, 2012 at 07:18:21AM -0400, Chuck Cook wrote:
> 
> https://github.com/trygvis/javax-usb-libusb1
> 
> You may find something here.  I am not sure how up to date it is.

It's hard to be out of date with a dead specification. It worked for everything I wanted, but I know there's
missing stuff. I'll be happy to accept good patches though.

Building it can be a bit of a pain, stuff that I depended on has changed a lot but it is possible :)

-- 
Trygve

> On 03/29/2012 12:47 AM, Hardik Shah wrote:
> >
> >Hi,
> >
> >I am working on a code which requires communication of java code
> >with usb device. For that I am using javax.usb api
> >
> >I was successfully able to send vendor specific commands that
> >control the usbDevice. Please find below snippet of code
> >
> >byte bmRequestType =  UsbConst.REQUESTTYPE_DIRECTION_OUT |
> >UsbConst.REQUESTTYPE_TYPE_CLASS |
> >UsbConst.REQUESTTYPE_RECIPIENT_INTERFACE;
> >
> >                                byte bRequest = 0x09;
> >
> >                                short wValue = 0x0300
> >
> >                                short wIndex = 0;
> >
> >                                byte[] buffer = {};// propertiary
> >command to be send to usbDevice
> >
> >                                UsbControlIrp usbControlIrp =
> >usbDevice.createUsbControlIrp(bmRequestType, bRequest, wValue,
> >wIndex);
> >
> >                                usbControlIrp.setData(buffer);
> >
> >                                usbDevice.syncSubmit(usbControlIrp);
> >
> >However I come across a situation where I need to get some
> >information back from usbDevice (i.e. I will send some command and
> >device will return the some specific information). In other words,
> >I need to  write some command to the device  and read response for
> >the same. How can I achieve this..?.   A code snippet or  working
> >example  will be helpful.
> >
> >Please find endpoint information
> >
> >                if (t == UsbConst.ENDPOINT_TYPE_INTERRUPT &&
> >ep.getDirection() == UsbConst.ENDPOINT_DIRECTION_IN
> >
> >&& ep.getUsbEndpointDescriptor().bEndpointAddress() ==
> >SCHOMAKER_ENDPOINT_ADDR ) {
> >
> >endptIn = ep;
> >
> >System.out.println("DEBUG AbstractCardReader endpoint is selected " );
> >
> >foundEp = true;
> >
> >                                                                break;
> >
> >Thanks
> >
> >Shah
> >
> >
> >
> >------------------------------------------------------------------------------
> >This SF email is sponsosred by:
> >Try Windows Azure free for 90 days Click Here
> >http://p.sf.net/sfu/sfd2d-msazure
> >
> >
> >_______________________________________________
> >javax-usb-devel mailing list
> >javax-usb-devel <at> lists.sourceforge.net
> >https://lists.sourceforge.net/lists/listinfo/javax-usb-devel

> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here 
> http://p.sf.net/sfu/sfd2d-msazure

> _______________________________________________
> javax-usb-devel mailing list
> javax-usb-devel <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure

Gmane