BrickNotFoundError

1,067 views
Skip to first unread message

Aurelio

unread,
Feb 28, 2012, 11:32:56 PM2/28/12
to nxt-python
Hi, I have started making a project in my school using nxt's and I was
wondering if could use python to program the nxt, then I discovered
this package that seems to be incredible!!! But, sadly I have not be
able to connect succesfully my nxt, and I don't know why, that's why I
am asking for help.

I have installed pyUsb, pyfantom, and libUsb (the one that pyusb
requires), also I installed the one for bluetooth just in case that i
may use it latter with a usb for bluetooth because my laptop does not
have bluetooth.

I have the nxt connected via the usb that comes in the box with it, I
have the nxt on, with the newest mindstorms version from lego for the
firmware. I created the make config file and I wrote:

[Brick]
name = 4511-E
method = usb=True, bluetooth=False, fantomusb=False

I didn't specify anything else because I don't know how to get that
info, but with the name and method sould be sufficient, I think.

But when I write:

import nxt
b = nxt.locator.find_one_brick()

I get this:

Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
b = nxt.locator.find_one_brick()
File "C:\Python26\lib\site-packages\nxt\locator.py", line 137, in
find_one_brick
raise BrickNotFoundError
BrickNotFoundError

I also tried this:

import nxt
b = nxt.locator.find_bricks().next().connect()

and I get this:

Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
b = nxt.locator.find_bricks().next().connect()
StopIteration

I have a windows 7 machine and python 2.6. Please help me, I really
need help to get my nxt working with python, I need to finish the
project as soon as posible. Thank you very much, and thankyou for
supporting this awesome package.

Marcus Wanner

unread,
Feb 29, 2012, 1:53:43 PM2/29/12
to nxt-p...@googlegroups.com
On Tue, Feb 28, 2012 at 08:32:56PM -0800, Aurelio wrote:
> I have installed pyUsb, pyfantom, and libUsb (the one that pyusb
> requires), also I installed the one for bluetooth just in case that i
> may use it latter with a usb for bluetooth because my laptop does not
> have bluetooth.
>
> I have the nxt connected via the usb that comes in the box with it, I
> have the nxt on, with the newest mindstorms version from lego for the
> firmware. I created the make config file and I wrote:
>
> [Brick]
> name = 4511-E
> method = usb=True, bluetooth=False, fantomusb=False

This looks good aside from missing MAC. There's a blurb on how to find
it here:
http://code.google.com/p/nxt-python/wiki/FAQ

> I didn't specify anything else because I don't know how to get that
> info, but with the name and method sould be sufficient, I think.

That should be correct. See above for instructions on getting the MAC,
which would probably help but is not required.

> But when I write:
>
> import nxt
> b = nxt.locator.find_one_brick()
>
> I get this:
>
> Traceback (most recent call last):
> File "<pyshell#1>", line 1, in <module>
> b = nxt.locator.find_one_brick()
> File "C:\Python26\lib\site-packages\nxt\locator.py", line 137, in
> find_one_brick
> raise BrickNotFoundError
> BrickNotFoundError

This means that something bad happened while it was looking for bricks.
Call it like this:
b = nxt.locator.find_one_brick(debug=True)
and post the output. That should tell you exactly what's going on.

> I also tried this:
>
> import nxt
> b = nxt.locator.find_bricks().next().connect()
>
> and I get this:
>
> Traceback (most recent call last):
> File "<pyshell#5>", line 1, in <module>
> b = nxt.locator.find_bricks().next().connect()
> StopIteration

Not much point in doing this. Looks like you're doing it wrong, and it's
not relevant enough for me to try to figure out the right way.

> I have a windows 7 machine and python 2.6. Please help me, I really
> need help to get my nxt working with python, I need to finish the
> project as soon as posible. Thank you very much, and thankyou for
> supporting this awesome package.

Thanks for the awesome issue description. If everyone reported problems
like this, the world would be a more awesome place. Hope we can get this
fixed!

--
Marcus Wanner

signature.asc

Aurelio

unread,
Feb 29, 2012, 9:14:40 PM2/29/12
to nxt-python
Thank you for all your help, and I was surprised how fast I got an
answer, making this group even better!

I changed the config file like this (now that I know the MAC):

[Brick]
host = 00:16:53:0D:1E:E4
name = 4511-E
method = usb=True, bluetooth=False, fantomusb=False

Sadly I am still getting the error :(, so I passed debug as true
hopping that you may know what's happening:

import nxt
b = nxt.locator.find_one_brick(debug = True)
Host: 00:16:53:0D:1E:E4 Name: 4511-E Strict: True
USB: True BT: False Fantom: False FUSB: False FBT: False

Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
b = nxt.locator.find_one_brick(debug = True)
File "C:\Python26\lib\site-packages\nxt\locator.py", line 137, in
find_one_brick
raise BrickNotFoundError
BrickNotFoundError

Again, thank you and I really apreciate everything you do here to
help!!!
>  signature.asc
> < 1 KBVerDescargar

Marcus Wanner

unread,
Mar 1, 2012, 12:13:17 PM3/1/12
to nxt-p...@googlegroups.com
On Wed, Feb 29, 2012 at 06:14:40PM -0800, Aurelio wrote:
> Thank you for all your help, and I was surprised how fast I got an
> answer, making this group even better!

Yeah, a most of the people who have contributed significantly to the
project hang around here. It's great when something arcane that they've
studied in detail breaks or when I'm not around for a few days and
someone asks a question.

> I changed the config file like this (now that I know the MAC):
>
> [Brick]
> host = 00:16:53:0D:1E:E4
> name = 4511-E
> method = usb=True, bluetooth=False, fantomusb=False

This looks good.

> Sadly I am still getting the error :(, so I passed debug as true
> hopping that you may know what's happening:
>
> import nxt
> b = nxt.locator.find_one_brick(debug = True)
> Host: 00:16:53:0D:1E:E4 Name: 4511-E Strict: True
> USB: True BT: False Fantom: False FUSB: False FBT: False
>
> Traceback (most recent call last):
> File "<pyshell#1>", line 1, in <module>
> b = nxt.locator.find_one_brick(debug = True)
> File "C:\Python26\lib\site-packages\nxt\locator.py", line 137, in
> find_one_brick
> raise BrickNotFoundError
> BrickNotFoundError

I was expecting more output than this...what hardware version is your
NXT? It looks like it isn't even seen at all. Are you sure it's plugged
in? Do other software packages recognize it? Another possible step to
take here is putting "strict=False" in your config file.

> Again, thank you and I really apreciate everything you do here to
> help!!!

You're welcome!

--
Marcus Wanner

signature.asc

Aurelio

unread,
Mar 10, 2012, 1:06:52 PM3/10/12
to nxt-python
Sorry, if I took my time to answer :( (I was on a school trip)

Ok, I don't know the hardware version, the brick is from the school
and it came in a box with lego pieces, it seems to be this box:http://
www.ratolab.be/downloads/lego/NXT%20information.pdf (the box is on the
page 11)

Yes, I have tried the brick in the graphical interface that comes with
it (I think it is RobotLab) and also I have tried it in RobotC, and
both of them work fine.

If it is helpful I can also show all the info that shows in the menu
of NXT version:

FW 1.31
AVR 1.01
BC4 1.01
BUILD 1903101214
ID 0016530D1EE4

Ok, so I tried to put "strict=False" in the config file:

[Brick]
strict = False
host = 00:16:53:0D:1E:E4
name = 4511-E
method = usb=True, bluetooth=False, fantomusb=False

But it gives me an error:

import nxt
b = nxt.locator.find_one_brick(debug = True)

Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
b = nxt.locator.find_one_brick()
File "C:\Python26\lib\site-packages\nxt\locator.py", line 104, in
find_one_brick
strict = bool(int(conf.get('Brick', 'strict')))
ValueError: invalid literal for int() with base 10: 'False'

So I checked the locator module and I discovered that is waiting for
an integer not "False"
so I changed the config file like this (because normally 0 is False):

[Brick]
strict = 0
host = 00:16:53:0D:1E:E4
name = 4511-E
method = usb=True, bluetooth=False, fantomusb=False

and I get this:

b = nxt.locator.find_one_brick(debug = True)
Host: 00:16:53:0D:1E:E4 Name: 4511-E Strict: False
USB: True BT: False Fantom: False FUSB: False FBT: False

Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
b = nxt.locator.find_one_brick(debug = True)
File "C:\Python26\lib\site-packages\nxt\locator.py", line 138, in
find_one_brick
raise BrickNotFoundError
BrickNotFoundError

then I also tried with strict as true:

[Brick]
strict = 1
host = 00:16:53:0D:1E:E4
name = 4511-E
method = usb=True, bluetooth=False, fantomusb=False

and I get this (It does not seem that the 1 changed anything in the
variable Strict):

b = nxt.locator.find_one_brick(debug = True)
Host: 00:16:53:0D:1E:E4 Name: 4511-E Strict: False
USB: True BT: False Fantom: False FUSB: False FBT: False

Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
b = nxt.locator.find_one_brick(debug = True)
File "C:\Python26\lib\site-packages\nxt\locator.py", line 138, in
find_one_brick
raise BrickNotFoundError
BrickNotFoundError

If there is other way to test it tell me and I wiil try.
Thankyou!!!
>  signature.asc
> < 1 KBVerDescargar

Marcus Wanner

unread,
Mar 10, 2012, 4:26:33 PM3/10/12
to nxt-p...@googlegroups.com
On Sat, Mar 10, 2012 at 10:06:52AM -0800, Aurelio wrote:
> Sorry, if I took my time to answer :( (I was on a school trip)
>
> Ok, I don't know the hardware version, the brick is from the school
> and it came in a box with lego pieces, it seems to be this box:http://
> www.ratolab.be/downloads/lego/NXT%20information.pdf (the box is on the
> page 11)

Thanks. I suppose there's not a huge difference.

> Yes, I have tried the brick in the graphical interface that comes with
> it (I think it is RobotLab) and also I have tried it in RobotC, and
> both of them work fine.

This is good.

> If it is helpful I can also show all the info that shows in the menu
> of NXT version:
>
> FW 1.31
> AVR 1.01
> BC4 1.01
> BUILD 1903101214
> ID 0016530D1EE4

Looking good again.

> Ok, so I tried to put "strict=False" in the config file:
>
> [Brick]
> strict = False
> host = 00:16:53:0D:1E:E4
> name = 4511-E
> method = usb=True, bluetooth=False, fantomusb=False
>
> But it gives me an error:
>
> import nxt
> b = nxt.locator.find_one_brick(debug = True)
>
> Traceback (most recent call last):
> File "<pyshell#1>", line 1, in <module>
> b = nxt.locator.find_one_brick()
> File "C:\Python26\lib\site-packages\nxt\locator.py", line 104, in
> find_one_brick
> strict = bool(int(conf.get('Brick', 'strict')))
> ValueError: invalid literal for int() with base 10: 'False'
>
> So I checked the locator module and I discovered that is waiting for
> an integer not "False"
> so I changed the config file like this (because normally 0 is False):
>
> [Brick]
> strict = 0
> host = 00:16:53:0D:1E:E4
> name = 4511-E
> method = usb=True, bluetooth=False, fantomusb=False

Yep, thats right. Sorry about that.

> and I get this:
>
> b = nxt.locator.find_one_brick(debug = True)
> Host: 00:16:53:0D:1E:E4 Name: 4511-E Strict: False
> USB: True BT: False Fantom: False FUSB: False FBT: False
>
> Traceback (most recent call last):
> File "<pyshell#3>", line 1, in <module>
> b = nxt.locator.find_one_brick(debug = True)
> File "C:\Python26\lib\site-packages\nxt\locator.py", line 138, in
> find_one_brick
> raise BrickNotFoundError
> BrickNotFoundError

This is interesting. It didn't see any brick at all, which means that
your brick might have different IDs from the other bricks nxt-python
has been tested with. This is kind of a wild guess, but it seems the
most likely from the debugging info you've given.

> If there is other way to test it tell me and I wiil try.

Could you run this?

import usb
for bus in usb.busses():
for device in bus.devices:
print device.idVendor, device.idProduct

That will print a list of the device and product IDs of everything
attached. One of them should be the NXT. Unplug all the non-NXT usb
hardware that you can before running that so it's easier to see which
one it is. Thanks!

--
Marcus Wanner

signature.asc

Aurelio

unread,
Mar 11, 2012, 1:29:46 AM3/11/12
to nxt-python
Ok, herw there are the results of the test:

import usb
for bus in usb.busses():
for device in bus.devices:
print device.idVendor, device.idProduct


4337 6708
4337 6708

I have two usb ports (I suppose those are the ports), ans I tried the
same with different devices pluged to the different ports and I get
the same output for all of them.
I tried just the nxt, then my mouse, then both of them, then nothing
but I still get the same output.

Thankyou again, and I need to mention that the RobotC and RobotLab
tests I made were on another computer, I didn't tried them on this
one. But when I plug in the usb with the nxt windows makes the noise
and it is showed on the devices menu (as an unknow device).

On 10 mar, 13:26, Marcus Wanner <mar...@wanners.net> wrote:
> On Sat, Mar 10, 2012 at 10:06:52AM -0800, Aurelio wrote:
> > Sorry, if I took my time to answer :( (I was on a school trip)
>
> > Ok, I don't know the hardware version, the brick is from the school
> > and it came in a box with lego pieces, it seems to be this box:http://
> >www.ratolab.be/downloads/lego/NXT%20information.pdf(the box is on the
>  signature.asc
> < 1 KBVerDescargar

Marcus Wanner

unread,
Mar 11, 2012, 5:52:06 PM3/11/12
to nxt-p...@googlegroups.com
On Sat, Mar 10, 2012 at 10:29:46PM -0800, Aurelio wrote:
> Ok, herw there are the results of the test:
>
> import usb
> for bus in usb.busses():
> for device in bus.devices:
> print device.idVendor, device.idProduct
>
>
> 4337 6708
> 4337 6708
>
> I have two usb ports (I suppose those are the ports), ans I tried the
> same with different devices pluged to the different ports and I get
> the same output for all of them.
> I tried just the nxt, then my mouse, then both of them, then nothing
> but I still get the same output.

Oh, if only everyone asking for help tested like this. Thank you!

> Thankyou again, and I need to mention that the RobotC and RobotLab
> tests I made were on another computer, I didn't tried them on this
> one. But when I plug in the usb with the nxt windows makes the noise
> and it is showed on the devices menu (as an unknow device).

It looks like pyusb/libusb can't see your devices. I would suggest
tracking down the maintainers of those and seeing if they have any more
troubleshooting you can do. I'm not an expert at these, so I can't
really help you out much more here. Sorry!

Good luck!

--
Marcus Wanner

signature.asc

Aurelio

unread,
Mar 13, 2012, 9:48:35 PM3/13/12
to nxt-python
YES!!!! Thank you!!

My computer was the problem (I don't know why), but now i don´t care
because it works with a school's laptop, so it does not matter at all.

The bad part is that it takes a long time to connect (like 25 sec) and
that in some cases it does not connect at all, but once the connection
is made it does not loose it :)

I may ask you a favor... I am using the hitechnic MotorCon, and I just
want to know how to use the class, the thing is that in methods like
this one:

def set_power(self, mot, power):
"""Set the power (-100-100) for a motor
"""
self.write_value('m%dpower'%mot, (power, ))

it asks for a parameter called mot and I don´t know what it is, I have
the hitechnic MotorCon setted and working under RobotC, but I just
want to know how to use it in nxt-python, thank you so much! I really
appreciate it.
>  signature.asc
> < 1 KBVerDescargar

Marcus Wanner

unread,
Mar 14, 2012, 9:47:54 PM3/14/12
to nxt-p...@googlegroups.com
On Tue, Mar 13, 2012 at 06:48:35PM -0700, Aurelio wrote:
> My computer was the problem (I don't know why), but now i don´t care
> because it works with a school's laptop, so it does not matter at all.

Interesting.

> The bad part is that it takes a long time to connect (like 25 sec) and
> that in some cases it does not connect at all, but once the connection
> is made it does not loose it :)

This sounds like something the bluetooth module would do. Not sure why
USB would do this or how to fix it, sorry...

> I may ask you a favor... I am using the hitechnic MotorCon, and I just
> want to know how to use the class, the thing is that in methods like
> this one:
>
> def set_power(self, mot, power):
> """Set the power (-100-100) for a motor
> """
> self.write_value('m%dpower'%mot, (power, ))
>
> it asks for a parameter called mot and I don´t know what it is, I have
> the hitechnic MotorCon setted and working under RobotC, but I just
> want to know how to use it in nxt-python, thank you so much! I really
> appreciate it.

That's going to be the number 1 or 2, looking at the source. Also keep
in mind this message from the docstrings:

"Object for HiTechnic FIRST Motor Controllers. Coded to HiTechnic's
specs for the sensor but not tested. Please report whether this worked
for you or not!"

It might be a bumpy ride. Let me know how it goes. Thanks!

--
Marcus Wanner

signature.asc

Aurelio

unread,
Mar 15, 2012, 9:59:09 PM3/15/12
to nxt-python
OK, so I got some info bad:

First it wasn't the computer it was the USB module I don't know why,
and yes it takes a while because it's using bluetooth (something that
the other computer has), so it seems prety good (it has a very good
range for the bluetooth).

Yep! The controllers are working, I just have tested the set_power
method, but that's the most important part. Something else, I want to
know is how do you deal with more than one controlller per port? (at
least in RobotC is posible), becuase they can be conected between them
(they have two ports per controller for that reason).

One more thing (and this is the last one), is it possible to have more
than one brick at the time working and how (because it seems there is
just one configuration file)?

Thank you so much.
>  signature.asc
> < 1 KBVerDescargar

Marcus Wanner

unread,
Mar 18, 2012, 8:44:26 PM3/18/12
to nxt-p...@googlegroups.com
On Thu, Mar 15, 2012 at 06:59:09PM -0700, Aurelio wrote:
> Yep! The controllers are working, I just have tested the set_power
> method, but that's the most important part. Something else, I want to
> know is how do you deal with more than one controlller per port? (at
> least in RobotC is posible), becuase they can be conected between them
> (they have two ports per controller for that reason).

Great, thanks!

> One more thing (and this is the last one), is it possible to have more
> than one brick at the time working and how (because it seems there is
> just one configuration file)?

Ah, it appears that I've overlooked this in designing the config file
format. Dear me... You can set everything in the file manually when you
call find_one_brick(), but this is not optimal for scripts meant to be
distributed for obvious reasons. In your case, I suppose the script
isn't meant to be published, so it wouldn't really hurt to just pass the
location information for the second brick directly to find_one_brick().
See the link below for details.

http://code.google.com/p/nxt-python/source/browse/trunk/nxt/locator.py#83

--
Marcus Wanner

signature.asc

Aurelio

unread,
Mar 21, 2012, 1:40:13 AM3/21/12
to nxt-python
Thankyou again, now I can happily finish my project. It seems to be
working pretty good with the particle filter and dynamic programming I
implemented on it, and its GUI running over the robot, I am really
happy.
> http://code.google.com/p/nxt-python/source/browse/trunk/nxt/locator.p...

G-man

unread,
Mar 29, 2012, 12:46:34 AM3/29/12
to nxt-python
This is a great thread, and I hope you all don't mind that I jump in
on here...

So following this thread, I was able to move forward and make great
progress, but I didn't have the great success that Aurelio seemed to
get to.

Where I appear to stumble is that I do seem to get to the right USB
connection, but then I get the error:

Failed to connect to possible brick

The reason I am confident that I am making the right connection is
that if I disconnect the USB cable, I never get the "Failed to connect
to possible brick" and am just told that 'BrickNotFoundError'.

I am further convinced that I am communicating with the NXT because I
notice that the USB "icon" on the NXT changes from USB to a different
"icon". Basically, it changes to a backward c with a line, to a
forward c (as follows - image that the first 'c' is backwards) c--c

Here is my full exception (note the 2 added debug messages - added in
locator.py):

Host: None Name: None Strict: True
USB: True BT: False Fantom: False FUSB: False FBT: False
searching USB None
None
<--- I added this debug message
socks: USB
()
<---- I added this debug message (tells me that it found one USB
connection)
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/nxt/locator.py", line 121,
in find_one_brick
Failed to connect to possible brick
info = b.get_device_info()
File "/Library/Python/2.7/site-packages/nxt/brick.py", line 27, in
poll
self.sock.send(str(ogram))
File "/Library/Python/2.7/site-packages/nxt/usbsock.py", line 69, in
send
self.handle.bulkWrite(self.blk_out.address, data)
File "/Library/Python/2.7/site-packages/usb/legacy.py", line 148, in
bulkWrite
return self.dev.write(endpoint, buffer, self.__claimed_interface,
timeout)
File "/Library/Python/2.7/site-packages/usb/core.py", line 610, in
write
intf = self._ctx.get_interface(self, interface)
File "/Library/Python/2.7/site-packages/usb/core.py", line 153, in
get_interface
cfg = self.get_active_configuration(device)
File "/Library/Python/2.7/site-packages/usb/core.py", line 169, in
get_active_configuration
raise USBError('Configuration not set')
USBError: [Errno None] Configuration not set
Traceback (most recent call last):
File "/Users/Gnunez/sqa/mindstorm/nxt-python-2.2.1/examples/
spin.py", line 18, in <module>
b = nxt.locator.find_one_brick(debug=True)
File "/Library/Python/2.7/site-packages/nxt/locator.py", line 139,
in find_one_brick
raise BrickNotFoundError
nxt.locator.BrickNotFoundError


I've tried this on two separate machines (a macpro and a mac mini)
with the exact same results. I also tried it with two different NXT
units.

Help would be greatly appreciated.

George

Marcus Wanner

unread,
Mar 29, 2012, 11:45:16 AM3/29/12
to nxt-p...@googlegroups.com
On Wed, Mar 28, 2012 at 09:46:34PM -0700, G-man wrote:
> Host: None Name: None Strict: True
> USB: True BT: False Fantom: False FUSB: False FBT: False
> searching USB None
> None
> <--- I added this debug message
> socks: USB
> ()
> <---- I added this debug message (tells me that it found one USB
> connection)
> Traceback (most recent call last):
<snip>

> cfg = self.get_active_configuration(device)
> File "/Library/Python/2.7/site-packages/usb/core.py", line 169, in
> get_active_configuration
> raise USBError('Configuration not set')
> USBError: [Errno None] Configuration not set
> Traceback (most recent call last):
> File "/Users/Gnunez/sqa/mindstorm/nxt-python-2.2.1/examples/
> spin.py", line 18, in <module>
> b = nxt.locator.find_one_brick(debug=True)
> File "/Library/Python/2.7/site-packages/nxt/locator.py", line 139,
> in find_one_brick
> raise BrickNotFoundError
> nxt.locator.BrickNotFoundError
>
>
> I've tried this on two separate machines (a macpro and a mac mini)
> with the exact same results. I also tried it with two different NXT
> units.

It looks like there's an issue with how we use the bluetooth library.
Try commenting out lines 47 and 48 of usbsock.py (see link below),
reinstalling, and testing again.

http://code.google.com/p/nxt-python/source/browse/trunk/nxt/usbsock.py#47

Thanks! Sorry about this.

--
Marcus Wanner

signature.asc

G-man

unread,
Mar 29, 2012, 11:57:21 AM3/29/12
to nxt-python
Doh!!!! You are a genius! That did it!

George
> http://code.google.com/p/nxt-python/source/browse/trunk/nxt/usbsock.p...
>
> Thanks! Sorry about this.
>
> --
> Marcus Wanner
>
>  signature.asc
> < 1KViewDownload

Ben Smith

unread,
Jun 28, 2014, 10:06:35 AM6/28/14
to nxt-p...@googlegroups.com
anyone still post here - im trying to get a raspi working with an nxt?
Reply all
Reply to author
Forward
0 new messages