[Sugar-devel] TA NXT plugin - cleanup and faster startup

Martin Langhoff martin.langhoff at gmail.com
Wed Mar 23 13:38:12 EDT 2011


On Wed, Mar 23, 2011 at 12:54 PM, Martin Langhoff
<martin.langhoff at gmail.com> wrote:
> One situation that is not handled well is unplugging/replugging of the
> usb cable -- which may well happen between "runs" in a busy classroom.
>
> We could address that by wrapping every call to the NXT libs with a
> try/except that retries the _find_brick() and retries the command.

I've actually updated my patch to use a small command dispatcher, so
all calls to the nxt library look like

  self._nxt_cmd(lambda: Motor(self.nxtbrick, port).turn(power, int(turns*360)))

which means we can easily wrap them to try and retry. With this, I can
unplug and replug my robot between executions, and it all works
perfectly well.

The lamba+dispatcher trick adds a layer of indirection, but the
stacktraces still make sense. And it's a lot more usable!

Remaining issues:

 - Sometimes TA gets stuck, probably in the "finding nxt brick" stage.
Is there a way to get a timeout on this? Is there a way to display a
message (like logoerror does) and then remove the msg once we found
our brick?

 - One of the blocks isn't readable (in English at least) -- I can't
figure out how to make meaningful customizations of the
"basic-style-3arg".

It's generally looking really neat.



m
-- 
 martin.langhoff at gmail.com
 martin at laptop.org -- Software Architect - OLPC
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff


More information about the Sugar-devel mailing list