massive commit to get umass working, only significant known bug is that changes don...
[goodfet] / client / goodfet.maxusbhost
1 #!/usr/bin/env python
2
3 #GoodFET MAXIM MAX3421 Host
4 #by Travis Goodspeed
5
6 import sys;
7 import binascii;
8 import array;
9 import time;
10 import warnings
11
12 from GoodFETMAXUSB import GoodFETMAXUSBHost;
13
14 warnings.warn(
15 """The libraries upon which this program depends will soon be deprecated in
16 favor of the USB*.py libraries.  The new libraries do not yet support host
17 mode, but an example will be written and documented when they do."""
18 )
19
20 if(len(sys.argv)==1):
21     print "Usage: %s verb [objects]\n" % sys.argv[0];
22     print "%s info" % sys.argv[0];
23     print "%s allstrings" % sys.argv[0];
24     sys.exit();
25
26
27 #Initialize FET and set baud rate
28 client=GoodFETMAXUSBHost();
29 client.serInit()
30
31
32 client.MAXUSBsetup();
33
34 client.hostinit();
35 client.usbverbose=False;
36
37 if(sys.argv[1]=="info"):
38     client.hostrun();
39
40 if(sys.argv[1]=="allstrings"):
41     print "This will try to print all strings from the target device.";
42     client.detect_device();
43     time.sleep(0.2);
44     client.enumerate_device();
45     for foo in range(1,255):
46         print "Grabbing string at index=%i" % foo;
47         string=client.getDescriptorString(foo);
48         if string!=None:
49             print "Strings[%i]=%s" % (foo,string);
50         sys.stdout.flush();