To further the below, I have now tested both on windows and linux with the same
result. It always takes until the 4th read call until my response appears,
even with the delay between reads set to zero. This seems like read() is
causing some state machine to progress..?? I will probably just wrap the read
call with a for loop that runs 4x -- but this seems like quite a hack.
Is there any documentation on how your logging module is configured? Id like to
know more about what is happening on my read calls.
Also, is there any way to check if / how much data is waiting on a bulk in ep
without 'reading' the data?
If the above 4x read calls are progressing a state machine, is there a way to
directly advance the state machine?
Thanks --- fyi, im quite new to pyusb / lib usb but have written an embedded
usb cdc host so have some familiarity with usb etc.
Walker
-Walker
-------- Original message --------
From: Walker Inman
Date:05/01/2014 5:21 PM (GMT-05:00)
To: pyusb-users@lists.sourceforge.net
Subject: [pyusb-users] read function
I'm having a bit of difficulty reading from my device.. It seems that I have to
make the Device.read() call multiple times in order to get the response. I
wrote a short test code that inserts a variable delay between reads.
Regardless of the delay value it seems to always take 3 or 4 read() calls
before I get my response. Please see below. d is an instance of
usb.core.Device.
any ideas why this is happening???
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
Type "copyright", "credits" or "license" for more information.
IPython 1.2.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
could not detach kernel driver index 1
could not detach kernel driver index 2
In [1]: speedtest??
Type: function
String Form:<function speedtest at 0x7ffba6f6e048>
File: /home/walker/software/stopsen/testing/py_usb.py
Definition: speedtest(d, delay=0.1)
Source:
def speedtest( d, delay = 0.1 ):
d.write(2, 'a')
for i in range(5):
time.sleep(delay)
print("{0}: {1}".format(i + 1, "".join(chr(a) for a in d.read(0x81, 20))))
In [2]: speedtest( d, .2 )
1:
2:
3:
4: 1403-OS4X-0303-0008
5:
In [3]: speedtest( d, .1 )
1:
2:
3:
4: 1403-OS4X-0303-0008
5:
In [4]: speedtest( d, 1 )
1:
2:
3:
4: 1403-OS4X-0303-0008
5:
In [5]: speedtest( d, 2 )
1:
2:
3:
4: 1403-OS4X-0303-0008
5:
In [6]:
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos. Get
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos. Get
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users