Raspberry Pi to NXT Code Problems

465 views
Skip to first unread message

hubble...@gmail.com

unread,
Sep 12, 2013, 3:14:20 PM9/12/13
to nxt-p...@googlegroups.com
Hello,
I need some help with my NXT.
I've tested out the python-nxt module for my mindstorms nxt (2.0) and coded for fun in python 2.7. But there were some problems. Btw i've already installed the pybluez-, pyusb- and pyfantom-modules to my Raspberry Pi. As i wrote
>>>import nxt
>>>nxt.find_one_brick()
to the console, it responsed:

Running on Linux Platform

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    nxt.find_one_brick()
  File "/usr/local/lib/python2.7/dist-packages/nxt/locator.py", line 112, in find_one_brick
    for s in find_bricks(host, name, silent, method):
  File "/usr/local/lib/python2.7/dist-packages/nxt/locator.py", line 65, in find_bricks
    import fantomsock
  File "/usr/local/lib/python2.7/dist-packages/nxt/fantomsock.py", line 15, in <module>
    import pyfantom
  File "pyfantom.py", line 70, in <module>
    raise RuntimeError("Fantom Driver not found")
RuntimeError: Fantom Driver not found

I have tested it with an on NXT and an off NXT at a active usb-hub and at both usb-ports on the Raspberry Pi
and ervery time i get this error.
But if i wrote:
>>>import nxt.locator
>>>nxt.locator.make_config()
it worked without problems.

So I think the Fantom Driver isn't installed on my Raspberry Pi and the official LEGO MINDSTORMS website has
only the Drivers for Windows PC and Mac.
I hope you can help me ;)

Nice greetings,
Hubble.Pixel

Btw: I sorry if i wrote bad english, it is not my native language :P
Message has been deleted

TC Wan

unread,
Sep 12, 2013, 11:31:31 PM9/12/13
to nxt-p...@googlegroups.com

There is no fantom driver for Raspberry Pi. It is only available for Mac OS X and Windows.
You should add a .nxt-python init file to your home directory:

$ cat .nxt-python
[Brick]
name =
host =
strict = 0
method = usb=False, bluetooth=False, fantomusb=False, fantombt=False

Change usb to True or bluetooth to True. The fantom* entries should be false.
Message has been deleted
Message has been deleted

hubble...@gmail.com

unread,
Sep 13, 2013, 10:58:31 AM9/13/13
to nxt-p...@googlegroups.com
Hello TC Wan,

thank you for your answer, this is my second time to answer you, my first answer has been deleted and i don't know why :(

I have changed my .nxt-python file to this:

[Brick]
name = MyNXT
host = 54:32:59:92:F9:39
strict = 0
method = usb=True, bluetooth=False, fantomusb=False, fantombt=False

Btw: On the screen of the NXT-Brick is the name not MyNXT, it's just NXT. Should I change it? And what is with the host and the strict?

I don't know but there is also a problem. Every time I write this in the IDLE (2.7):
>>>import nxt
>>>nxt.find_one_brick()

this is the output:

Traceback (most recent call last):
  File "<pyshell#7>", line 1, in <module>
    nxt.find_one_brick()
  File "/usr/local/lib/python2.7/dist-packages/nxt/locator.py", line 137, in find_one_brick
    raise BrickNotFoundError
BrickNotFoundError

My NXT-Brick is connected to the up one usb-port of my Raspberry Pi B board.

When I try the debug-mode of this command:

>>>import nxt
>>>nxt.find_one_brick(debug=True)

this is the output to the shell:

Host: 54:32:59:92:F9:39 Name: MyNXT Strict: True
USB: True BT: False Fantom: False FUSB: False FBT: False
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/nxt/locator.py", line 118, in find_one_brick
    b = s.connect()
  File "/usr/local/lib/python2.7/dist-packages/nxt/usbsock.py", line 45, in connect
    self.handle.setConfiguration(1)
USBError: could not set config 1: Operation not permitted
Failed to connect to possible brick

Traceback (most recent call last):
  File "<pyshell#12>", line 1, in <module>
    nxt.find_one_brick(debug=True)
  File "/usr/local/lib/python2.7/dist-packages/nxt/locator.py", line 137, in find_one_brick
    raise BrickNotFoundError
BrickNotFoundError

There is the shown, that the usbsock.py-module has no permissions to set config1. I don't know what is config1.
I gave both modules permissions to execute (sudo chmod +x) but it don't work :(

Please help me.
Hubble.Pixel

Marcus Wanner

unread,
Sep 14, 2013, 7:30:38 PM9/14/13
to nxt-p...@googlegroups.com
On Fri, Sep 13, 2013 at 07:58:31AM -0700, hubble...@gmail.com wrote:
> USBError: could not set config 1: Operation not permitted
> Failed to connect to possible brick
>
> There is the shown, that the usbsock.py-module has no permissions to set
> config1. I don't know what is config1.
> I gave both modules permissions to execute (sudo chmod +x) but it don't
> work :(

All you should have to do is add the udev rule in the Installation
instructions.

--
Marcus Wanner
signature.asc
Message has been deleted

hubble...@gmail.com

unread,
Sep 16, 2013, 11:14:52 AM9/16/13
to nxt-p...@googlegroups.com
I have already created the 70-lego.rules file at /etc/udev/rules.d/
with following text:

SUBSYSTEM=="usb", ATTRS{idVendor}=="0694", GROUP="lego", MODE="0660"

Should I do more?

Marcus Wanner

unread,
Sep 16, 2013, 11:52:22 AM9/16/13
to nxt-p...@googlegroups.com
You also need to restart udev (or reboot if you're feeling lazy) and
add yourself to the lego group and log out and back in again.

--
Marcus Wanner
signature.asc

TC Wan

unread,
Sep 17, 2013, 11:11:15 PM9/17/13
to nxt-p...@googlegroups.com


On Friday, September 13, 2013 10:58:31 PM UTC+8, hubble...@gmail.com wrote:
Hello TC Wan,

thank you for your answer, this is my second time to answer you, my first answer has been deleted and i don't know why :(


I hope you managed to get it to work. I think Marcus answered most of your other questions.
I just saw the earlier post in my mailbox.

In reply, fantombt is used for controlling the Fantom Bluetooth driver. 


Marcus Wanner

unread,
Sep 18, 2013, 5:40:50 PM9/18/13
to nxt-p...@googlegroups.com
On Tue, Sep 17, 2013 at 08:11:15PM -0700, TC Wan wrote:
> On Friday, September 13, 2013 10:58:31 PM UTC+8, hubble...@gmail.com wrote:
> > thank you for your answer, this is my second time to answer you, my first
> > answer has been deleted and i don't know why :(
>
> I just saw the earlier post in my mailbox.

Yeah, sorry about that. Google Groups moderation leaves a lot to be
desired and I'm erring on the side of not forwarding spam to the entire
list.

--
Marcus Wanner
signature.asc

hubble...@gmail.com

unread,
Sep 19, 2013, 2:33:23 PM9/19/13
to nxt-p...@googlegroups.com
Hello TcWan, hello Marcus, 

I am sorry to have to inform you but none of your suggestions has worked in any way. Everytime, when I have attached my Lego-Brick (he is always plugged in to the upper USB port at the Raspberry Pi and is connected with a USB-A to USB-B cable). 

How always came if I have opened the python 2. 7. 3, IDLE, and first: 

> > > import nxt/import nxt. locator 

and then: 

> > > nxt. find_one_brick ()/nxt. locator. find_one_brick ( ) 

the BrickNotFoundError has typed, came. 

I must say to this what my .nxt-python file looks like: 


[Brick] 
name = NXT 
host = 00:16:53:15:27:5 A 
strict = 1 
method = usb = True, Bluetooth = False, fantomusb = False, fantombt = False 

I have if I can see above that the name of the Bricks NXT is as stand type-like, mean much to my Brick in front of me predefinedly. 
If I am changed to the Settings list after that and have selected the NXT version there, this came: 

FW 1. 31 
AVR 1. 01 
BC4 1. 01 
BUILD 1903101214 
ID 00165315275A

I know that the ID is the MAC address and must be registered in the .nxt-python file as a host. Is the rest also important, then? FW probably stands for firmware. 

I hope you can do something with that. If not, then I already have booked a new SD card and try once again there to do everything from the front. 

I apologize if I have used a little sbad or wrong English again as said, am I no Englishman and have translated this long text by PONS. eu once ): 

Nice greetings, Hubble.Pixel

Marcus Wanner

unread,
Sep 19, 2013, 3:00:51 PM9/19/13
to nxt-p...@googlegroups.com
On Thu, Sep 19, 2013 at 11:33:23AM -0700, hubble...@gmail.com wrote:
> > > > nxt. find_one_brick ()/nxt. locator. find_one_brick ( )
>
> the BrickNotFoundError has typed, came.

Please always run find_one_brick(debug=True) and post the output when
you're reporting BrickNotFoundErrors.

> [Brick]
> name = NXT
> host = 00:16:53:15:27:5 A
> strict = 1
> method = usb = True, Bluetooth = False, fantomusb = False, fantombt = False

If you only have one brick connected, just set strict = 0. No reason to
enable it.

--
Marcus Wanner
signature.asc

hubble...@gmail.com

unread,
Sep 19, 2013, 3:21:14 PM9/19/13
to nxt-p...@googlegroups.com
So here is your wished output by debug=True:

Host: 00:16:53:15:27:5A Name: NXT Strict: True
USB: True BT: False Fantom: False FUSB: False FBT: False
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/nxt/locator.py", line 118, in find_one_brick
    b = s.connect()
  File "/usr/local/lib/python2.7/dist-packages/nxt/usbsock.py", line 45, in connect
    self.handle.setConfiguration(1)
USBError: could not set config 1: Operation not permitted
Failed to connect to possible brick

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    nxt.find_one_brick(debug=True)
  File "/usr/local/lib/python2.7/dist-packages/nxt/locator.py", line 137, in find_one_brick
    raise BrickNotFoundError
BrickNotFoundError

Marcus Wanner

unread,
Sep 19, 2013, 3:27:37 PM9/19/13
to nxt-p...@googlegroups.com
On Thu, Sep 19, 2013 at 12:21:14PM -0700, hubble...@gmail.com wrote:
> USBError: could not set config 1: Operation not permitted

So yeah, you need to add yourself to the lego group like I said.
Instructions for this may be found on the Installation wiki page or via
google, but this will probably work:

groupadd lego
gpasswd -a pi lego

Run as root, substitute your username for "pi". You'll need to log out and
back in again afterwards as I said.

--
Marcus Wanner
signature.asc

hubble...@gmail.com

unread,
Sep 20, 2013, 7:33:00 AM9/20/13
to nxt-p...@googlegroups.com
Hey Marcus,
 
I did everything you said, I tried this commands and rebooted my Raspberry Pi. After this, I checked if the 70-lego.rules file is correct (like the Wiki said) and checked the .nxt-python-file everything was right. And then came the fail :(

Output by my console (yes, I wrote also debug=True):

Host: 00:16:53:15:27:5A Name: NXT Strict: True
USB: True BT: False Fantom: False FUSB: False FBT: False
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/nxt/locator.py", line 118, in find_one_brick
    b = s.connect()
  File "/usr/local/lib/python2.7/dist-packages/nxt/usbsock.py", line 45, in connect
    self.handle.setConfiguration(1)
USBError: could not set config 1: Operation not permitted
Failed to connect to possible brick

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    nxt.locator.find_one_brick(debug=True)
  File "/usr/local/lib/python2.7/dist-packages/nxt/locator.py", line 137, in find_one_brick
    raise BrickNotFoundError
BrickNotFoundError

I don't know what I am doing wrong :( I did everything you said.
Could it be that there is a problem with other installed packages or ClamAV? My Anti-Virus programme?

NG Hubble.Pixel

Marcus Wanner

unread,
Sep 20, 2013, 9:17:43 AM9/20/13
to nxt-p...@googlegroups.com
On Fri, Sep 20, 2013 at 04:33:00AM -0700, hubble...@gmail.com wrote:
> I did everything you said, I tried this commands and rebooted my
> Raspberry Pi. After this, I checked if the 70-lego.rules file is
> correct (like the Wiki said) and checked the .nxt-python-file
> everything was right. And then came the fail :(
>
> USBError: could not set config 1: Operation not permitted

If all else fails, just run python as root. It's not pretty or a good
idea, but it'll fix the problem.

--
Marcus Wanner
signature.asc

hubble...@gmail.com

unread,
Sep 20, 2013, 10:09:03 AM9/20/13
to nxt-p...@googlegroups.com
Hello Marcus,

I am so an Idiot, I forgot that you can run everything as root :D
But as you said it is not the best idea. I hope it will work anytime with a normal Rasp Pi User and not with root, but thank you very much for helping me.

Now I am going to code something.... big :D

@TcWan, @Marcus your help helped (often).

Nice Greetings,
Hubble.Pixel

Gabriel Cronin

unread,
Apr 15, 2015, 10:37:48 PM4/15/15
to nxt-p...@googlegroups.com
Hi All,

I am having a very similar problem on a Raspberry pi connected up to an NXT.  I have following the installation instructions exactly including installing nxt.python (no errors), using root (on a debian machine) to install python-usb, running groupadd lego and usermod -a -G lego pi as root, setting up the file 70-lego.rules, and also configuring the .nxt-python file with the appropriate information as shown below:

[Brick] 
name = 6157 
host = 00:16:53:1A:9A:D5 
strict = 0
method = usb = True, Bluetooth = False, fantomusb = True

I have setup .nxt-python files in both the account pi/home and also in root/home

I get the same error sequence when i run nxt.locator.find_one_brick(debug=True) as either the pi user or as a root user.  Please see the attached picture.


The nxt is plugged into a USB hub, but i have tried to connect it also directly into the USB ports on the pi.  Same error in both cases.  

I also tried a script to find the vendor and product id:

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

 which shows me that those values are 1682 and 2 for the NXT (since those values disappear and reappear as i plug in or unplug the NXT)

any suggestions?
Reply all
Reply to author
Forward
0 new messages