From: [EMAIL PROTECTED]
Reply-To: javax-usb-devel@lists.sourceforge.net
To: javax-usb-devel@lists.sourceforge.net
Subject: javax-usb-devel Digest, Vol 5, Issue 4
Date: Tue, 07 Nov 2006 08:01:27 -0800
Send javax-usb-devel mailing list submissions to
javax-usb-devel@lists.sourceforge.net
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
or, via email, send a message with subject or body 'help' to
[EMAIL PROTECTED]
You can reach the person managing the list at
[EMAIL PROTECTED]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of javax-usb-devel digest..."
Today's Topics:
1. Re: Help - able to send and recieve data from DLP design usb
(Stefan Banke)
2. Re: Help - able to send and recieve data from DLP design usb
(Dan Streetman)
----------------------------------------------------------------------
Message: 1
Date: Tue, 07 Nov 2006 12:02:49 +0000
From: "Stefan Banke" <[EMAIL PROTECTED]>
Subject: Re: [javax-usb-devel] Help - able to send and recieve data
from DLP design usb
To: javax-usb-devel@lists.sourceforge.net
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; format=flowed
I have tested the board with the TestApp software getting the following
correct
respons:
send:
0x1, 0xA7, 0xA6
recieve:
0x55, 0x32, 0x34, 0x35, 0x53, 0x59.
send:
0x3, 0xA6, 0xE5, 0x1, 0x41
recieve:
0x55
send:
0x2, 0xAF, 0x14, 0xB9
recieve:
0x55, 0x14
When I test the board with my own software I get the correct respons but
only once.
ex:
0x2, 0xAF, 0x14, 0xB9 -> 0x55, 0x14
The respons is seen like this more or less.
send: 0x2, 0xAF, 0x14, 0xB9
recieve: 0x31, 0x00, 0x14......and a later byte array 0x31, 0x00, 0x55.....
sow I get 0x14 and 0x55 but allways with 0x31 first. When I run the code
again I get:
send: 0x2, 0xAF, 0x14, 0xB9
recieve: 0x31, 0x60, 0x00......and a later byte array 0x31, 0x60, 0x00.....
Do I get a buffer overflow somewhere?? And error should return 0xAA.
Kind regards
Stefan Banke
>From: [EMAIL PROTECTED]
>Reply-To: javax-usb-devel@lists.sourceforge.net
>To: javax-usb-devel@lists.sourceforge.net
>Subject: javax-usb-devel Digest, Vol 5, Issue 2
>Date: Sat, 04 Nov 2006 12:12:15 -0800
>
>Send javax-usb-devel mailing list submissions to
> javax-usb-devel@lists.sourceforge.net
>
>To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
>or, via email, send a message with subject or body 'help' to
> [EMAIL PROTECTED]
>
>You can reach the person managing the list at
> [EMAIL PROTECTED]
>
>When replying, please edit your Subject line so it is more specific
>than "Re: Contents of javax-usb-devel digest..."
>
>
>Today's Topics:
>
> 1. Re: Help - able to send and recieve data from DLP design usb
> chip - but only once!! (Dan Streetman)
> 2. Re: reverse engineering USB (David A Scott) (Noel O'Brien)
>
>
>----------------------------------------------------------------------
>
>Message: 1
>Date: Fri, 3 Nov 2006 15:37:06 -0500
>From: "Dan Streetman" <[EMAIL PROTECTED]>
>Subject: Re: [javax-usb-devel] Help - able to send and recieve data
> from DLP design usb chip - but only once!!
>To: "Stefan Banke" <[EMAIL PROTECTED]>
>Cc: javax-usb-devel@lists.sourceforge.net
>Message-ID:
> <[EMAIL PROTECTED]>
>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>Do you know the protocol of your device? That behavior could be
>completely correct.
>
>On 10/29/06, Stefan Banke <[EMAIL PROTECTED]> wrote:
> > Hello
> >
> > I am able to send and recieve data from a DLP design usb chip - but
just
>one
> > time per endpoint. When I send a loopback ex. data[0] = (byte)0x2;
>data[1]
> > = (byte)0xAF; data[2] = (byte)0x14; data[3] = (byte)0xBF; I then
get
>a
> > 0x31 the first time, then I run the code again and I get the loopback
>0x31,
> > 0x60, "0x14" the "0x14" from the input.... and an exception.....
> >
> > this is the code:
> >
> >
>------------------------------------------------------------------------------------------------------------------
> >
> > /*
> > * UsbComm.java
> > *
> > * Created on 18. oktober 2006, 09:00
> > *
> > * To change this template, choose Tools | Template Manager
> > * and open the template in the editor.
> > */
> >
> > /**
> > *
> > * @author kaptajnen
> > */
> >
> >
> > import java.util.*;
> > import javax.usb.*;
> > import javax.usb.util.*;
> > import java.io.*;
> > import java.lang.*;
> >
> >
> > public class UsbComm extends Thread
> > {
> >
> > /** Creates a new instance of UsbComm */
> > public UsbComm()
> > {
> > }
> >
> > /**
> > * @param args the command line arguments
> > */
> > public static void main(String argv[])
> > {
> > UsbHub virtualRootUsbHub = getVirtualRootUsbHub();
> > List allUsbDevices =
>getAllUsbDevices(virtualRootUsbHub);
> > List usbHubs =
>getUsbDevicesWithDeviceClass(virtualRootUsbHub,
> > UsbConst.HUB_CLASSCODE);
> >
> > System.out.println("Found " + allUsbDevices.size() + "
>devices total.");
> > System.out.println("Found " + allUsbDevices.size() + "
>non-hub devices.");
> > System.out.println("Value of allUsbDevices index 0 "+
> > allUsbDevices.get(0));
> > //System.out.println("Value of allUsbDevices index 1
"+
> > allUsbDevices.get(1));
> >
> > allUsbDevices.removeAll(usbHubs);
> >
> > System.out.println("Found " + allUsbDevices.size() + "
>non-hub devices.");
> >
> > if (0 < allUsbDevices.size()) {
> >
> >
> > UsbDevice usbDevice =
>(UsbDevice)allUsbDevices.get(1);
> >
> > testIO(usbDevice);
> >
> > } else {
> > System.out.println("No non-hub devices were
>found.");
> > }
> > }
> >
> > public static UsbHub getVirtualRootUsbHub()
> > {
> > UsbServices services2 = null;
> > UsbHub virtualRootUsbHub = null;
> >
> > /* First we need to get the UsbServices.
> > * This might throw either an UsbException or
>SecurityException.
> > * A SecurityException means we're not allowed to
access
>the USB bus,
> > * while a UsbException indicates there is a problem
>either in
> > * the javax.usb implementation or the OS USB support.
> > */
> > try {
> > services2 = UsbHostManager.getUsbServices();
> > } catch ( UsbException uE ) {
> > throw new RuntimeException("Error : " +
>uE.getMessage());
> > } catch ( SecurityException sE ) {
> > throw new RuntimeException("Error : " +
>sE.getMessage());
> > }
> >
> > /* Now we need to get the virtual root UsbHub,
> > * everything is connected to it. The Virtual Root
>UsbHub
> > * doesn't actually correspond to any physical device,
>it's
> > * strictly virtual. Each of the devices connected to
>one of its
> > * ports corresponds to a physical host controller
>located in
> > * the system. Those host controllers are (usually)
>located inside
> > * the computer, e.g. as a PCI board, or a chip on the
>mainboard,
> > * or a PCMCIA card. The virtual root UsbHub
aggregates
>all these
> > * host controllers.
> > *
> > * This also may throw an UsbException or
>SecurityException.
> > */
> > try {
> > virtualRootUsbHub = services2.getRootUsbHub();
> > } catch ( UsbException uE ) {
> > throw new RuntimeException("Error : " +
>uE.getMessage());
> > } catch ( SecurityException sE ) {
> > throw new RuntimeException("Error : " +
>sE.getMessage());
> > }
> >
> > return virtualRootUsbHub;
> > }
> > public static List getAllUsbDevices(UsbDevice usbDevice)
> > {
> > List list = new ArrayList();
> >
> > list.add(usbDevice);
> >
> > /* this is just normal recursion. Nothing special. */
> > if (usbDevice.isUsbHub()) {
> > List devices =
>((UsbHub)usbDevice).getAttachedUsbDevices();
> > for (int i=0; i<devices.size(); i++)
> >
>list.addAll(getAllUsbDevices((UsbDevice)devices.get(i)));
> > }
> >
> > return list;
> > }
> >
> > public static List getUsbDevicesWithDeviceClass(UsbDevice
>usbDevice,
> > byte deviceClass)
> > {
> > List list = new ArrayList();
> >
> > /* See above about comparing unsigned numbers, note
this
>is an unsigned
> > byte. */
> > if (deviceClass ==
>usbDevice.getUsbDeviceDescriptor().bDeviceClass())
> > list.add(usbDevice);
> >
> > /* this is just normal recursion. Nothing special. */
> > if (usbDevice.isUsbHub()) {
> > List devices =
>((UsbHub)usbDevice).getAttachedUsbDevices();
> > for (int i=0; i<devices.size(); i++)
> >
>list.addAll(getUsbDevicesWithDeviceClass((UsbDevice)devices.get(i),
> > deviceClass));
> > }
> >
> > return list;
> > }
> > public static void testIO(UsbDevice device)
> > {
> > try
> > {
> >
> > String manufacturer = device.getManufacturerString();
> > System.out.println("manufacturer: "+manufacturer);
> >
> > // Access to the active configuration of the USB device,
obtain
> > // all the interfaces available in that configuration.
> > UsbConfiguration config = device.getActiveUsbConfiguration();
> > List totalInterfaces = config.getUsbInterfaces();
> >
> >
> > int antal = totalInterfaces.size();
> > System.out.println("antal interfaces "+ antal);
> >
> > // Traverse through all the interfaces, and access the
endpoints
> > // available to that interface for I/O.
> > for (int i=0; i<totalInterfaces.size(); i++)
> > {
> >
> >
> > //hvilket inderface hentes??
> >
> > UsbInterface interf = (UsbInterface)
totalInterfaces.get(i);
> >
> > //Interfacet tvinges til tilhorsforhold - vaer paapasselig
>med
> > hvilket interface der kraves adgang til!!
> > interf.claim(new UsbInterfacePolicy()
> > {
> > public boolean forceClaim(UsbInterface usbInterface)
> > {
> > return true;
> > }
> > }
> > );
> >
> > String interfacetext = interf.getInterfaceString();
> > System.out.println("interface text: "+interfacetext);
> >
> > //boolean test_isclaimed = interf.isClaimed();
> > //System.out.println("interface er gjort krav paa:
> > "+test_isclaimed);
> >
> >
> > //boolean test_isactive = interf.isActive();
> > //System.out.println("interface er aktivt:
"+test_isactive);
> >
> > List totalEndpoints = interf.getUsbEndpoints();
> > int antalendpoints = totalEndpoints.size();
> > System.out.println("antal endpoints: "+antalendpoints);
> >
> >
> >
> > //----------------------------------------------------------------
> >
> >
> > UsbEndpoint inep = (UsbEndpoint) totalEndpoints.get(0);
> > Usbread ur = new Usbread(inep);
> > Thread ept = new Thread(ur);
> > ept.start();
> >
> > //----------------------------------------------------------------
> >
> > // Access the particular endpoint, determine the direction
> > // of its data flow, and type of data transfer, and open
>the
> > // data pipe for I/O.
> > UsbEndpoint ep = (UsbEndpoint) totalEndpoints.get(1);
> > int direction = ep.getDirection();
> > if (direction == UsbConst.ENDPOINT_DIRECTION_OUT)
> > {
> > System.out.println("endpoint: fra vaert (pc) til usb
> > enhed");
> > }
> > else
> > {
> > System.out.println("endpoint: fra usb enhed til vaert
> > (pc)");
> > }
> > int type = ep.getType();
> >
> > switch(type)
> > {
> > case UsbConst.ENDPOINT_TYPE_CONTROL:
> > System.out.println("control endpoint: der
>konfigurer og
> > kontrolere usb device og bus");
> > break;
> >
> > case UsbConst.ENDPOINT_TYPE_BULK:
> > System.out.println("bulk endpoint: data
transmision
> > uden tab af data");
> > break;
> >
> > case UsbConst.ENDPOINT_TYPE_INTERRUPT:
> > System.out.println("interrupt endpoint: et
> > foresporgsels endpoint type - bruges til kald");
> > break;
> >
> > case UsbConst.ENDPOINT_TYPE_ISOCHRONOUS:
> > System.out.println("asynckront transmision
>endpoint:
> > transmision med garanteret data hastighed");
> > break;
> > default:
> > System.out.println("ikke genkendt type");
> > }
> >
> > UsbPipe pipe = ep.getUsbPipe();
> >
> > // Her starter selve USB I/O
> >
> > int maxPakkeStorrelse =
> > ep.getUsbEndpointDescriptor().wMaxPacketSize();
> > System.out.println("maks pakke storrelse: "+
> > maxPakkeStorrelse);
> >
> > UsbIrp irp = pipe.createUsbIrp();
> >
> >
> > pipe.open();
> >
> > byte[] data = new byte[maxPakkeStorrelse];
> >
> >
> > //data[0] = (byte)0x03;
> > //data[1] = (byte)0xA6;
> > //data[2] = (byte)0xE5;
> > //data[3] = (byte)0x1;
> > //data[4] = (byte)0x41;
> >
> > data[0] = (byte)0x2;
> > data[1] = (byte)0xAF;
> > data[2] = (byte)0x14;
> > data[3] = (byte)0xBF;
> >
> > irp.setData(data);
> > irp.setUsbException(null);
> > //irp.setComplete(false); //setcomplete skal s?ttes til
>false
> > ved genbrug af pipe
> >
> > pipe.syncSubmit(irp);
> >
> > for(i=0; i<10; i++)
> > {
> > String usbtestnr = UsbUtil.toHexString(data[i]);
> > System.out.println(usbtestnr);
> > }
> >
> >
> > irp.setComplete(false);
> > pipe.abortAllSubmissions();
> >
> >
> > // Her slutter selve USB I/O
> > pipe.close();
> >
> >
> > interf.release();
> > }
> > } catch (Exception e) {System.out.println("claim exception hvis
usb
>er
> > inaktivt eller allerede tilhore andet interface!!");}
> > }
> >
> >
> > }
> >
> >
>-----------------------------------------------------------------------------------------------------------
> >
> >
> > /*
> > * Usbread.java
> > *
> > * Created on 28. oktober 2006, 09:40
> > *
> > * To change this template, choose Tools | Template Manager
> > * and open the template in the editor.
> > */
> >
> > /**
> > *
> > * @author kaptajnen
> > */
> >
> > import java.util.*;
> > import javax.usb.*;
> > import javax.usb.util.*;
> > import java.io.*;
> > import java.lang.*;
> >
> >
> > public class Usbread implements Runnable
> > {
> >
> > UsbEndpoint inep;
> > /** Creates a new instance of Usbread */
> > public Usbread(UsbEndpoint ep)
> > {
> > inep=ep;
> > }
> > public void run()
> > {
> > try
> > {
> > // Access the particular endpoint, determine the direction
> > // of its data flow, and type of data transfer, and open
>the
> > // data pipe for I/O.
> >
> > UsbPipe pipein = inep.getUsbPipe();
> > pipein.open();
> > // Her starter selve USB I/O
> >
> > int inmaxPakkeStorrelse =
> > inep.getUsbEndpointDescriptor().wMaxPacketSize();
> > System.out.println("maks pakke storrelse: "+
> > inmaxPakkeStorrelse);
> >
> > UsbIrp irpin = pipein.createUsbIrp();
> > byte[] datain = new byte[inmaxPakkeStorrelse];
> >
> > irpin.setData(datain);
> > irpin.setUsbException(null);
> > //irpin.setComplete(false);//setcomplete skal s?ttes til
>false
> > ved genbrug af pipe
> >
> > pipein.syncSubmit(irpin);
> >
> > for(int i=0; i<10; i++)
> > {
> > String usbtestnr = UsbUtil.toHexString(datain[i]);
> > System.out.println(usbtestnr);
> > }
> >
> > irpin.setComplete(false);
> >
> > pipein.abortAllSubmissions();
> >
> > // Her slutter selve USB I/O
> > pipein.close();
> > }
> > catch (Exception e) {System.out.println("Er der nogen expetion
> > her??");}
> > }
> >
> > }
> >
> >
> >
> > Kind regards
> >
> > Stefan Banke
> >
> > _________________________________________________________________
> > Find dine dokumenter lettere med MSN Toolbar med Windows-pc-s?gning:
> > http://toolbar.msn.dk
> >
> >
> >
> >
> >
>-------------------------------------------------------------------------
> > Using Tomcat but need to do more? Need to support web services,
>security?
> > Get stuff done quickly with pre-integrated technology to make your job
>easier
> > Download IBM WebSphere Application Server v.1.0.1 based on Apache
>Geronimo
> >
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> >
> > _______________________________________________
> > javax-usb-devel mailing list
> > javax-usb-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
> >
> >
> >
>
>
>
>------------------------------
>
>Message: 2
>Date: Sat, 4 Nov 2006 07:58:58 -0800 (PST)
>From: Noel O'Brien <[EMAIL PROTECTED]>
>Subject: Re: [javax-usb-devel] reverse engineering USB (David A Scott)
>To: javax-usb-devel@lists.sourceforge.net
>Message-ID: <[EMAIL PROTECTED]>
>Content-Type: text/plain; charset=iso-8859-1
>
>
> > I need to do some reverse engineering of some camera interactions.
> >
> > I've Never done this for USB devices before. What setup do
> > you recommend? Are there any programs that will make this
> > easier? (I've used utils for other protocols that sure made
> > life easier. :)
> >
>
>There are some programs around that you can use in Windows to 'snoop' on
>the traffic being sent to
>and from your device under normal operation. I can think of the URLs of
the
>programs. There are a
>few of them; just type "USB snoop" into google and it should point you in
>the right direction
>
>Good Luck,
>Noel
>
>
>
>
>__________________________________________________________________________________________
>Check out the New Yahoo! Mail - Fire up a more powerful email and get
>things done faster.
>(http://advision.webevents.yahoo.com/mailbeta)
>
>
>
>
>------------------------------
>
>-------------------------------------------------------------------------
>Using Tomcat but need to do more? Need to support web services, security?
>Get stuff done quickly with pre-integrated technology to make your job
>easier
>Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>
>------------------------------
>
>_______________________________________________
>javax-usb-devel mailing list
>javax-usb-devel@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
>
>
>End of javax-usb-devel Digest, Vol 5, Issue 2
>*********************************************
_________________________________________________________________
Opret en personlig blog og del dine billeder på MSN Spaces:
http://spaces.msn.com/
------------------------------
Message: 2
Date: Tue, 7 Nov 2006 11:01:05 -0500
From: "Dan Streetman" <[EMAIL PROTECTED]>
Subject: Re: [javax-usb-devel] Help - able to send and recieve data
from DLP design usb
To: "Stefan Banke" <[EMAIL PROTECTED]>
Cc: javax-usb-devel@lists.sourceforge.net
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain; charset=UTF-8; format=flowed
I don't know the protocol of your device, so I can't tell you why it
responds the way it does...I looked briefly at your code and I have 2
suggestions:
1. in your Usbread class you should repeat the input continually, i.e.
the run() method should have a while (true) {} loop where you
syncSubmit() a UsbIrp and once it is done you repeat. Or, use a
UsbPipeListener (and resubmit the UsbIrp with that).
2. You are sending out more than just the 4 bytes. If you want to
limit the size to just the 4 bytes you want to send out, use
UsbIrp.setLength(4) or create a byte[4]. As your code is now you're
sending out extra uninitialized bytes that may confuse your device.
On 11/7/06, Stefan Banke <[EMAIL PROTECTED]> wrote:
> I have tested the board with the TestApp software getting the following
> correct
> respons:
>
> send:
> 0x1, 0xA7, 0xA6
> recieve:
> 0x55, 0x32, 0x34, 0x35, 0x53, 0x59.
>
> send:
> 0x3, 0xA6, 0xE5, 0x1, 0x41
> recieve:
> 0x55
>
> send:
> 0x2, 0xAF, 0x14, 0xB9
> recieve:
> 0x55, 0x14
>
> When I test the board with my own software I get the correct respons but
> only once.
>
> ex:
>
> 0x2, 0xAF, 0x14, 0xB9 -> 0x55, 0x14
>
> The respons is seen like this more or less.
>
> send: 0x2, 0xAF, 0x14, 0xB9
>
> recieve: 0x31, 0x00, 0x14......and a later byte array 0x31, 0x00,
0x55.....
>
> sow I get 0x14 and 0x55 but allways with 0x31 first. When I run the code
> again I get:
>
> send: 0x2, 0xAF, 0x14, 0xB9
>
> recieve: 0x31, 0x60, 0x00......and a later byte array 0x31, 0x60,
0x00.....
>
> Do I get a buffer overflow somewhere?? And error should return 0xAA.
>
> Kind regards
>
> Stefan Banke
>
>
> >From: [EMAIL PROTECTED]
> >Reply-To: javax-usb-devel@lists.sourceforge.net
> >To: javax-usb-devel@lists.sourceforge.net
> >Subject: javax-usb-devel Digest, Vol 5, Issue 2
> >Date: Sat, 04 Nov 2006 12:12:15 -0800
> >
> >Send javax-usb-devel mailing list submissions to
> > javax-usb-devel@lists.sourceforge.net
> >
> >To subscribe or unsubscribe via the World Wide Web, visit
> > https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
> >or, via email, send a message with subject or body 'help' to
> > [EMAIL PROTECTED]
> >
> >You can reach the person managing the list at
> > [EMAIL PROTECTED]
> >
> >When replying, please edit your Subject line so it is more specific
> >than "Re: Contents of javax-usb-devel digest..."
> >
> >
> >Today's Topics:
> >
> > 1. Re: Help - able to send and recieve data from DLP design
usb
> > chip - but only once!! (Dan Streetman)
> > 2. Re: reverse engineering USB (David A Scott) (Noel O'Brien)
> >
> >
> >----------------------------------------------------------------------
> >
> >Message: 1
> >Date: Fri, 3 Nov 2006 15:37:06 -0500
> >From: "Dan Streetman" <[EMAIL PROTECTED]>
> >Subject: Re: [javax-usb-devel] Help - able to send and recieve data
> > from DLP design usb chip - but only once!!
> >To: "Stefan Banke" <[EMAIL PROTECTED]>
> >Cc: javax-usb-devel@lists.sourceforge.net
> >Message-ID:
> > <[EMAIL PROTECTED]>
> >Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> >
> >Do you know the protocol of your device? That behavior could be
> >completely correct.
> >
> >On 10/29/06, Stefan Banke <[EMAIL PROTECTED]> wrote:
> > > Hello
> > >
> > > I am able to send and recieve data from a DLP design usb chip - but
just
> >one
> > > time per endpoint. When I send a loopback ex. data[0] = (byte)0x2;
> >data[1]
> > > = (byte)0xAF; data[2] = (byte)0x14; data[3] = (byte)0xBF; I then
get
> >a
> > > 0x31 the first time, then I run the code again and I get the
loopback
> >0x31,
> > > 0x60, "0x14" the "0x14" from the input.... and an exception.....
> > >
> > > this is the code:
> > >
> > >
>
>------------------------------------------------------------------------------------------------------------------
> > >
> > > /*
> > > * UsbComm.java
> > > *
> > > * Created on 18. oktober 2006, 09:00
> > > *
> > > * To change this template, choose Tools | Template Manager
> > > * and open the template in the editor.
> > > */
> > >
> > > /**
> > > *
> > > * @author kaptajnen
> > > */
> > >
> > >
> > > import java.util.*;
> > > import javax.usb.*;
> > > import javax.usb.util.*;
> > > import java.io.*;
> > > import java.lang.*;
> > >
> > >
> > > public class UsbComm extends Thread
> > > {
> > >
> > > /** Creates a new instance of UsbComm */
> > > public UsbComm()
> > > {
> > > }
> > >
> > > /**
> > > * @param args the command line arguments
> > > */
> > > public static void main(String argv[])
> > > {
> > > UsbHub virtualRootUsbHub = getVirtualRootUsbHub();
> > > List allUsbDevices =
> >getAllUsbDevices(virtualRootUsbHub);
> > > List usbHubs =
> >getUsbDevicesWithDeviceClass(virtualRootUsbHub,
> > > UsbConst.HUB_CLASSCODE);
> > >
> > > System.out.println("Found " + allUsbDevices.size() +
"
> >devices total.");
> > > System.out.println("Found " + allUsbDevices.size() +
"
> >non-hub devices.");
> > > System.out.println("Value of allUsbDevices index 0
"+
> > > allUsbDevices.get(0));
> > > //System.out.println("Value of allUsbDevices index 1
"+
> > > allUsbDevices.get(1));
> > >
> > > allUsbDevices.removeAll(usbHubs);
> > >
> > > System.out.println("Found " + allUsbDevices.size() +
"
> >non-hub devices.");
> > >
> > > if (0 < allUsbDevices.size()) {
> > >
> > >
> > > UsbDevice usbDevice =
> >(UsbDevice)allUsbDevices.get(1);
> > >
> > > testIO(usbDevice);
> > >
> > > } else {
> > > System.out.println("No non-hub devices were
> >found.");
> > > }
> > > }
> > >
> > > public static UsbHub getVirtualRootUsbHub()
> > > {
> > > UsbServices services2 = null;
> > > UsbHub virtualRootUsbHub = null;
> > >
> > > /* First we need to get the UsbServices.
> > > * This might throw either an UsbException or
> >SecurityException.
> > > * A SecurityException means we're not allowed to
access
> >the USB bus,
> > > * while a UsbException indicates there is a problem
> >either in
> > > * the javax.usb implementation or the OS USB
support.
> > > */
> > > try {
> > > services2 = UsbHostManager.getUsbServices();
> > > } catch ( UsbException uE ) {
> > > throw new RuntimeException("Error : " +
> >uE.getMessage());
> > > } catch ( SecurityException sE ) {
> > > throw new RuntimeException("Error : " +
> >sE.getMessage());
> > > }
> > >
> > > /* Now we need to get the virtual root UsbHub,
> > > * everything is connected to it. The Virtual Root
> >UsbHub
> > > * doesn't actually correspond to any physical
device,
> >it's
> > > * strictly virtual. Each of the devices connected
to
> >one of its
> > > * ports corresponds to a physical host controller
> >located in
> > > * the system. Those host controllers are (usually)
> >located inside
> > > * the computer, e.g. as a PCI board, or a chip on
the
> >mainboard,
> > > * or a PCMCIA card. The virtual root UsbHub
aggregates
> >all these
> > > * host controllers.
> > > *
> > > * This also may throw an UsbException or
> >SecurityException.
> > > */
> > > try {
> > > virtualRootUsbHub =
services2.getRootUsbHub();
> > > } catch ( UsbException uE ) {
> > > throw new RuntimeException("Error : " +
> >uE.getMessage());
> > > } catch ( SecurityException sE ) {
> > > throw new RuntimeException("Error : " +
> >sE.getMessage());
> > > }
> > >
> > > return virtualRootUsbHub;
> > > }
> > > public static List getAllUsbDevices(UsbDevice usbDevice)
> > > {
> > > List list = new ArrayList();
> > >
> > > list.add(usbDevice);
> > >
> > > /* this is just normal recursion. Nothing special.
*/
> > > if (usbDevice.isUsbHub()) {
> > > List devices =
> >((UsbHub)usbDevice).getAttachedUsbDevices();
> > > for (int i=0; i<devices.size(); i++)
> > >
> >list.addAll(getAllUsbDevices((UsbDevice)devices.get(i)));
> > > }
> > >
> > > return list;
> > > }
> > >
> > > public static List getUsbDevicesWithDeviceClass(UsbDevice
> >usbDevice,
> > > byte deviceClass)
> > > {
> > > List list = new ArrayList();
> > >
> > > /* See above about comparing unsigned numbers, note
this
> >is an unsigned
> > > byte. */
> > > if (deviceClass ==
> >usbDevice.getUsbDeviceDescriptor().bDeviceClass())
> > > list.add(usbDevice);
> > >
> > > /* this is just normal recursion. Nothing special.
*/
> > > if (usbDevice.isUsbHub()) {
> > > List devices =
> >((UsbHub)usbDevice).getAttachedUsbDevices();
> > > for (int i=0; i<devices.size(); i++)
> > >
> >list.addAll(getUsbDevicesWithDeviceClass((UsbDevice)devices.get(i),
> > > deviceClass));
> > > }
> > >
> > > return list;
> > > }
> > > public static void testIO(UsbDevice device)
> > > {
> > > try
> > > {
> > >
> > > String manufacturer = device.getManufacturerString();
> > > System.out.println("manufacturer: "+manufacturer);
> > >
> > > // Access to the active configuration of the USB device,
obtain
> > > // all the interfaces available in that configuration.
> > > UsbConfiguration config = device.getActiveUsbConfiguration();
> > > List totalInterfaces = config.getUsbInterfaces();
> > >
> > >
> > > int antal = totalInterfaces.size();
> > > System.out.println("antal interfaces "+ antal);
> > >
> > > // Traverse through all the interfaces, and access the
endpoints
> > > // available to that interface for I/O.
> > > for (int i=0; i<totalInterfaces.size(); i++)
> > > {
> > >
> > >
> > > //hvilket inderface hentes??
> > >
> > > UsbInterface interf = (UsbInterface)
totalInterfaces.get(i);
> > >
> > > //Interfacet tvinges til tilhorsforhold - vaer
paapasselig
> >med
> > > hvilket interface der kraves adgang til!!
> > > interf.claim(new UsbInterfacePolicy()
> > > {
> > > public boolean forceClaim(UsbInterface usbInterface)
> > > {
> > > return true;
> > > }
> > > }
> > > );
> > >
> > > String interfacetext = interf.getInterfaceString();
> > > System.out.println("interface text: "+interfacetext);
> > >
> > > //boolean test_isclaimed = interf.isClaimed();
> > > //System.out.println("interface er gjort krav paa:
> > > "+test_isclaimed);
> > >
> > >
> > > //boolean test_isactive = interf.isActive();
> > > //System.out.println("interface er aktivt:
"+test_isactive);
> > >
> > > List totalEndpoints = interf.getUsbEndpoints();
> > > int antalendpoints = totalEndpoints.size();
> > > System.out.println("antal endpoints: "+antalendpoints);
> > >
> > >
> > >
> > > //----------------------------------------------------------------
> > >
> > >
> > > UsbEndpoint inep = (UsbEndpoint) totalEndpoints.get(0);
> > > Usbread ur = new Usbread(inep);
> > > Thread ept = new Thread(ur);
> > > ept.start();
> > >
> > > //----------------------------------------------------------------
> > >
> > > // Access the particular endpoint, determine the
direction
> > > // of its data flow, and type of data transfer, and
open
> >the
> > > // data pipe for I/O.
> > > UsbEndpoint ep = (UsbEndpoint) totalEndpoints.get(1);
> > > int direction = ep.getDirection();
> > > if (direction == UsbConst.ENDPOINT_DIRECTION_OUT)
> > > {
> > > System.out.println("endpoint: fra vaert (pc) til usb
> > > enhed");
> > > }
> > > else
> > > {
> > > System.out.println("endpoint: fra usb enhed til
vaert
> > > (pc)");
> > > }
> > > int type = ep.getType();
> > >
> > > switch(type)
> > > {
> > > case UsbConst.ENDPOINT_TYPE_CONTROL:
> > > System.out.println("control endpoint: der
> >konfigurer og
> > > kontrolere usb device og bus");
> > > break;
> > >
> > > case UsbConst.ENDPOINT_TYPE_BULK:
> > > System.out.println("bulk endpoint: data
transmision
> > > uden tab af data");
> > > break;
> > >
> > > case UsbConst.ENDPOINT_TYPE_INTERRUPT:
> > > System.out.println("interrupt endpoint: et
> > > foresporgsels endpoint type - bruges til kald");
> > > break;
> > >
> > > case UsbConst.ENDPOINT_TYPE_ISOCHRONOUS:
> > > System.out.println("asynckront transmision
> >endpoint:
> > > transmision med garanteret data hastighed");
> > > break;
> > > default:
> > > System.out.println("ikke genkendt type");
> > > }
> > >
> > > UsbPipe pipe = ep.getUsbPipe();
> > >
> > > // Her starter selve USB I/O
> > >
> > > int maxPakkeStorrelse =
> > > ep.getUsbEndpointDescriptor().wMaxPacketSize();
> > > System.out.println("maks pakke storrelse: "+
> > > maxPakkeStorrelse);
> > >
> > > UsbIrp irp = pipe.createUsbIrp();
> > >
> > >
> > > pipe.open();
> > >
> > > byte[] data = new byte[maxPakkeStorrelse];
> > >
> > >
> > > //data[0] = (byte)0x03;
> > > //data[1] = (byte)0xA6;
> > > //data[2] = (byte)0xE5;
> > > //data[3] = (byte)0x1;
> > > //data[4] = (byte)0x41;
> > >
> > > data[0] = (byte)0x2;
> > > data[1] = (byte)0xAF;
> > > data[2] = (byte)0x14;
> > > data[3] = (byte)0xBF;
> > >
> > > irp.setData(data);
> > > irp.setUsbException(null);
> > > //irp.setComplete(false); //setcomplete skal s?ttes
til
> >false
> > > ved genbrug af pipe
> > >
> > > pipe.syncSubmit(irp);
> > >
> > > for(i=0; i<10; i++)
> > > {
> > > String usbtestnr = UsbUtil.toHexString(data[i]);
> > > System.out.println(usbtestnr);
> > > }
> > >
> > >
> > > irp.setComplete(false);
> > > pipe.abortAllSubmissions();
> > >
> > >
> > > // Her slutter selve USB I/O
> > > pipe.close();
> > >
> > >
> > > interf.release();
> > > }
> > > } catch (Exception e) {System.out.println("claim exception hvis
usb
> >er
> > > inaktivt eller allerede tilhore andet interface!!");}
> > > }
> > >
> > >
> > > }
> > >
> > >
>
>-----------------------------------------------------------------------------------------------------------
> > >
> > >
> > > /*
> > > * Usbread.java
> > > *
> > > * Created on 28. oktober 2006, 09:40
> > > *
> > > * To change this template, choose Tools | Template Manager
> > > * and open the template in the editor.
> > > */
> > >
> > > /**
> > > *
> > > * @author kaptajnen
> > > */
> > >
> > > import java.util.*;
> > > import javax.usb.*;
> > > import javax.usb.util.*;
> > > import java.io.*;
> > > import java.lang.*;
> > >
> > >
> > > public class Usbread implements Runnable
> > > {
> > >
> > > UsbEndpoint inep;
> > > /** Creates a new instance of Usbread */
> > > public Usbread(UsbEndpoint ep)
> > > {
> > > inep=ep;
> > > }
> > > public void run()
> > > {
> > > try
> > > {
> > > // Access the particular endpoint, determine the
direction
> > > // of its data flow, and type of data transfer, and
open
> >the
> > > // data pipe for I/O.
> > >
> > > UsbPipe pipein = inep.getUsbPipe();
> > > pipein.open();
> > > // Her starter selve USB I/O
> > >
> > > int inmaxPakkeStorrelse =
> > > inep.getUsbEndpointDescriptor().wMaxPacketSize();
> > > System.out.println("maks pakke storrelse: "+
> > > inmaxPakkeStorrelse);
> > >
> > > UsbIrp irpin = pipein.createUsbIrp();
> > > byte[] datain = new byte[inmaxPakkeStorrelse];
> > >
> > > irpin.setData(datain);
> > > irpin.setUsbException(null);
> > > //irpin.setComplete(false);//setcomplete skal s?ttes
til
> >false
> > > ved genbrug af pipe
> > >
> > > pipein.syncSubmit(irpin);
> > >
> > > for(int i=0; i<10; i++)
> > > {
> > > String usbtestnr = UsbUtil.toHexString(datain[i]);
> > > System.out.println(usbtestnr);
> > > }
> > >
> > > irpin.setComplete(false);
> > >
> > > pipein.abortAllSubmissions();
> > >
> > > // Her slutter selve USB I/O
> > > pipein.close();
> > > }
> > > catch (Exception e) {System.out.println("Er der nogen
expetion
> > > her??");}
> > > }
> > >
> > > }
> > >
> > >
> > >
> > > Kind regards
> > >
> > > Stefan Banke
> > >
> > > _________________________________________________________________
> > > Find dine dokumenter lettere med MSN Toolbar med Windows-pc-s?gning:
> > > http://toolbar.msn.dk
> > >
> > >
> > >
> > >
> > >
>
>-------------------------------------------------------------------------
> > > Using Tomcat but need to do more? Need to support web services,
> >security?
> > > Get stuff done quickly with pre-integrated technology to make your
job
> >easier
> > > Download IBM WebSphere Application Server v.1.0.1 based on Apache
> >Geronimo
> > >
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> > >
> > > _______________________________________________
> > > javax-usb-devel mailing list
> > > javax-usb-devel@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
> > >
> > >
> > >
> >
> >
> >
> >------------------------------
> >
> >Message: 2
> >Date: Sat, 4 Nov 2006 07:58:58 -0800 (PST)
> >From: Noel O'Brien <[EMAIL PROTECTED]>
> >Subject: Re: [javax-usb-devel] reverse engineering USB (David A Scott)
> >To: javax-usb-devel@lists.sourceforge.net
> >Message-ID: <[EMAIL PROTECTED]>
> >Content-Type: text/plain; charset=iso-8859-1
> >
> >
> > > I need to do some reverse engineering of some camera interactions.
> > >
> > > I've Never done this for USB devices before. What setup do
> > > you recommend? Are there any programs that will make this
> > > easier? (I've used utils for other protocols that sure made
> > > life easier. :)
> > >
> >
> >There are some programs around that you can use in Windows to 'snoop'
on
> >the traffic being sent to
> >and from your device under normal operation. I can think of the URLs of
the
> >programs. There are a
> >few of them; just type "USB snoop" into google and it should point you
in
> >the right direction
> >
> >Good Luck,
> >Noel
> >
> >
> >
> >
>
>__________________________________________________________________________________________
> >Check out the New Yahoo! Mail - Fire up a more powerful email and get
> >things done faster.
> >(http://advision.webevents.yahoo.com/mailbeta)
> >
> >
> >
> >
> >------------------------------
> >
>
>-------------------------------------------------------------------------
> >Using Tomcat but need to do more? Need to support web services,
security?
> >Get stuff done quickly with pre-integrated technology to make your job
> >easier
> >Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
>
>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> >
> >------------------------------
> >
> >_______________________________________________
> >javax-usb-devel mailing list
> >javax-usb-devel@lists.sourceforge.net
> >https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
> >
> >
> >End of javax-usb-devel Digest, Vol 5, Issue 2
> >*********************************************
>
> _________________________________________________________________
> Opret en personlig blog og del dine billeder p? MSN Spaces:
> http://spaces.msn.com/
>
>
>
>
>
-------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services,
security?
> Get stuff done quickly with pre-integrated technology to make your job
easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>
> _______________________________________________
> javax-usb-devel mailing list
> javax-usb-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
>
>
>
------------------------------
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
------------------------------
_______________________________________________
javax-usb-devel mailing list
javax-usb-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
End of javax-usb-devel Digest, Vol 5, Issue 4
*********************************************