summaryrefslogtreecommitdiffstats
path: root/toprammer
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2010-01-31 13:29:04 +0100
committerMichael Buesch <mb@bu3sch.de>2010-01-31 13:29:04 +0100
commit46c722dd516ca8f1fdfe1b4e84b72c15a4b116e1 (patch)
tree2ab45b5dd72444869b9ebc99b69da254dbdd51cd /toprammer
parent00e262102e9669409fa53d33090df894cc5e3665 (diff)
downloadtoprammer-46c722dd516ca8f1fdfe1b4e84b72c15a4b116e1.tar.xz
toprammer-46c722dd516ca8f1fdfe1b4e84b72c15a4b116e1.zip
Send blocked commands before reading
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Diffstat (limited to 'toprammer')
-rwxr-xr-xtoprammer13
1 files changed, 10 insertions, 3 deletions
diff --git a/toprammer b/toprammer
index 2aa9cab..6cbc9f9 100755
--- a/toprammer
+++ b/toprammer
@@ -281,6 +281,7 @@ class TOP:
raise TOPException("USB bulk write error: " + str(e))
def send(self, command):
+ """Send a raw command."""
assert(len(command) <= 64)
if self.commandsBlocked:
self.commandQueue.append(command)
@@ -288,7 +289,9 @@ class TOP:
self.__doSend(command)
def receive(self, size):
- assert(not self.commandsBlocked)
+ """Receive 'size' bytes on the bulk-in ep."""
+ # If there are blocked commands in the queue, send them now.
+ self.__flushCommands()
try:
ep = self.bulkIn.address
data = ""
@@ -309,10 +312,14 @@ class TOP:
self.commandsBlocked = True
def unblockCommands(self):
- """Flush the software command queue and send them to the device."""
+ """Flush and unblock the software command queue and send the
+ queued commands to the device."""
assert(self.commandsBlocked)
self.commandsBlocked = False
- # Flush the queue
+ self.__flushCommands()
+
+ def __flushCommands(self):
+ """Flush the command queue, but don't unblock it."""
command = ""
for oneCommand in self.commandQueue:
assert(len(oneCommand) <= 64)
bues.ch cgit interface