schodet / nxt-python

NXT-Python is a python driver/interface for the Lego Mindstorms NXT robot based on NXT_python.
https://ni.srht.site/nxt-python/latest/
GNU General Public License v3.0
237 stars 74 forks source link

Cant find brick #161

Closed Kainkun closed 2 years ago

Kainkun commented 4 years ago

Im having trouble getting this to work. When I do brick = nxt.locator.find_one_brick() I get this error

Traceback (most recent call last): File "g:\Documents\Python\NXTtest.py", line 4, in brick = nxt.locator.find_one_brick() File "C:\Users\Kainkun\Anaconda2\lib\site-packages\nxt\locator.py", line 112, in find_one_brick for s in find_bricks(host, name, silent, method): File "C:\Users\Kainkun\Anaconda2\lib\site-packages\nxt\locator.py", line 43, in find_bricks for s in socks: File "C:\Users\Kainkun\Anaconda2\lib\site-packages\nxt\usbsock.py", line 84, in find_bricks for bus in usb.busses(): File "C:\Users\Kainkun\Anaconda2\lib\site-packages\usb\legacy.py", line 352, in return (Bus(g) for k, g in groupby( File "C:\Users\Kainkun\Anaconda2\lib\site-packages\usb\legacy.py", line 347, in init self.devices = [Device(d) for d in devices] File "C:\Users\Kainkun\Anaconda2\lib\site-packages\usb\legacy.py", line 333, in init self.configurations = [Configuration(c) for c in dev] File "C:\Users\Kainkun\Anaconda2\lib\site-packages\usb\core.py", line 1094, in iter yield Configuration(self, i) File "C:\Users\Kainkun\Anaconda2\lib\site-packages\usb\core.py", line 586, in init configuration File "C:\Users\Kainkun\Anaconda2\lib\site-packages\usb\backend\libusb1.py", line 757, in get_configuration_descriptor
config, byref(cfg))) File "C:\Users\Kainkun\Anaconda2\lib\site-packages\usb\backend\libusb1.py", line 595, in _check raise USBError(_strerror(ret), ret, _libusb_errno[ret]) usb.core.USBError: [Errno 2] Entity not found

auryan898 commented 4 years ago

find_one_brick is sometimes difficult to work with, so if you are using exclusively just bluetooth or just usb, I suggest using the specific methods to do that. It seems that your code is attempting to connect via USB, but could not detect it. Is it plugged in? Will you do so? I assume LibUsb is installed, but it is just having trouble connecting.

Here is a past issue troubleshooting bluetooth connections, if that is what you are attempting: #121

Also installation instructions, in case you haven't already checked about connections: https://github.com/Eelviny/nxt-python/wiki/Installation

Kainkun commented 4 years ago

Thanks, I thought that find_one_brick is the only way to access the brick.

I tried this b = nxt.bluesock.BlueSock('00:16:53:07:6a:0b').connect() and got this.

Traceback (most recent call last): File "g:\Documents\Python\NXTtest.py", line 7, in b = nxt.bluesock.BlueSock('00:16:53:07:6a:0b').connect() File "C:\Users\Kainkun\Anaconda2\lib\site-packages\nxt\bluesock.py", line 39, in connect sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM) File "C:\Users\Kainkun\Anaconda2\lib\site-packages\nxt\lightblueglue.py", line 34, in init _sock = lightblue.socket(proto) AttributeError: 'module' object has no attribute 'socket'

Do you know whats going on? As for USB I'm trying what this is doing https://stackoverflow.com/questions/51603286/python-nxt-mindstorms-connection-issues

but I'm not sure how to set the config file

If there are different methods to connect please let me know. Thank you so much

On Sun, Apr 5, 2020 at 10:46 AM Ryan Au notifications@github.com wrote:

find_one_brick is sometimes difficult to work with, so if you are using exclusively just bluetooth or just usb, I suggest using the specific methods to do that. It seems that your code is attempting to connect via USB, but could not detect it. Is it plugged in? Will you do so? I assume LibUsb is installed, but it is just having trouble connecting.

Here is a past issue troubleshooting bluetooth connections, if that is what you are attempting: #121 https://github.com/Eelviny/nxt-python/issues/121

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Eelviny/nxt-python/issues/161#issuecomment-609455016, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGMR3X3HQS72TFZJ4IX6OZLRLC7V3ANCNFSM4L4XKU3Q .

schodet commented 2 years ago

It seems that you do not have PyBluez installed so it falls back to lightblue.

Can you try with PyBluez installed?

Please reopen if you still have the problem with python3, the master branch, and PyBluez.