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
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
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
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
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
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
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