On Linux, linxt will upload any file except a .rxe [SOLVED]

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
tcwan
Posts: 186
Joined: 30 Sep 2010, 07:39

Re: On Linux, linxt will upload any file except a .rxe [SOLVED]

Post by tcwan »

afanofosc wrote:Also, if you are interested, you could try integrating with my new libfantom.so shared library which implements the exact set of functions that LEGO/NI provide in the fantom.dll for Mac OSX and Windows.

John Hansen
Hi John,

Can you please provide more info on the libfantom.so library? I'd be interested in seeing if pyfantom can be made to work with it.
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: On Linux, linxt will upload any file except a .rxe [SOLVED]

Post by afanofosc »

This is entirely untested at this point, but if you can write a python wrapper to use the C API functions exported from fantom.dll on windows then, in theory, that same wrapper could be used with just slight modifications to work with libfantom.so on Linux. In my previous post I may not have been clear, but I only have implemented the C API functions that are exported by fantom.dll on Windows.

I don't think it is usable on other platforms at this point. My code on Mac OS X and Windows just links directly to the fantom library provided by LEGO/NI.

It would be easier, I think, to use the higher level API functions provided by libnxtspirit.so rather than to use the lower level Fantom API.

I googled a bit but could not find pyfantom. Where could I get this?

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
tcwan
Posts: 186
Joined: 30 Sep 2010, 07:39

Re: On Linux, linxt will upload any file except a .rxe [SOLVED]

Post by tcwan »

afanofosc wrote:This is entirely untested at this point, but if you can write a python wrapper to use the C API functions exported from fantom.dll on windows then, in theory, that same wrapper could be used with just slight modifications to work with libfantom.so on Linux. In my previous post I may not have been clear, but I only have implemented the C API functions that are exported by fantom.dll on Windows.

I don't think it is usable on other platforms at this point. My code on Mac OS X and Windows just links directly to the fantom library provided by LEGO/NI.

It would be easier, I think, to use the higher level API functions provided by libnxtspirit.so rather than to use the lower level Fantom API.

I googled a bit but could not find pyfantom. Where could I get this?

John Hansen
Nicolas Schodet (mostly) and I created pyfantom http://git.ni.fr.eu.org/?p=pyfantom.git;a=summary as python wrappers to the C API for the LEGO Fantom drivers. Basically it allows Python code to call the Fantom drivers on supported platforms (Mac & Windows). I was hoping that you've implemented the Fantom C API for Linux, which does not have Fantom support.

I've tested and am using pyfantom on Mac OS X Snow Leopard via nxt-python http://code.google.com/p/nxt-python/.
Granted that currently nxt-python on Linux accesses the libusb backend to communicate with the NXT, but the semantics are slightly different wrt. error handling.
Having a common Fantom backend on all 3 platforms would make higher level code easier to maintain.

T.C.
pepijndevos
Posts: 175
Joined: 28 Dec 2011, 13:07
Location: Gelderland, Netherlands
Contact:

Re: On Linux, linxt will upload any file except a .rxe [SOLVED]

Post by pepijndevos »

How do you run python-nxt with pyfantom on Mac? I'm running Python in 32-bit mode, and still experience frequent errors. I emailed Nicolas about it, and he said it was you who did most of the work. Interesting :)

What bothers me about Linux is that it requires root access to use USB.
-- Pepijn
http://studl.es Mindstorms Building Instructions
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: On Linux, linxt will upload any file except a .rxe [SOLVED]

Post by afanofosc »

I am sure that root access is not required to use usb (or bluetooth) on Linux, with the right configuration.

If you grab my new 45-legonxt.rules file (https://bricxcc.svn.sourceforge.net/svn ... onxt.rules) and make sure that your user account is a member of the legonxt group then it should just work without requiring sudo or root access. Follow these guidelines (which I will be updating soon):

http://bricxcc.sourceforge.net/nbc/doc/nxtlinux.txt

I can provide an intel 32-bit binary of libfantom.so if anyone would like to experiment with it on Linux. It does require libusb 0.1.

John
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
tcwan
Posts: 186
Joined: 30 Sep 2010, 07:39

Re: On Linux, linxt will upload any file except a .rxe [SOLVED]

Post by tcwan »

pepijndevos wrote:How do you run python-nxt with pyfantom on Mac? I'm running Python in 32-bit mode, and still experience frequent errors. I emailed Nicolas about it, and he said it was you who did most of the work. Interesting :)

What bothers me about Linux is that it requires root access to use USB.
Well, Nicolas is the Python guru, so the class design is his. I just filled in the blanks.

Hmm. Which Mac OSX version? I've tested it on Snow Leopard (10.6).
Also, are you using the default Apple python, or from MacPorts? Both should work, though from macports you would need to compile it as universal to get the 32-bit version.

pyfantom will complain unless you invoke python with
$arch -i386 $PYTHON

For the Apple supplied version, you need to provide the full python executable name, python2.6, for e.g., otherwise the python wrapper does not invoke the actual python interpreter correctly for 32-bit operation.

Code: Select all

iMac-TCWan:pyfantom tcmac$ python pyfantom.py
Traceback (most recent call last):
  File "pyfantom.py", line 17, in <module>
    raise RuntimeError("fantom drivers not available in 64 bit mode.\n"
RuntimeError: fantom drivers not available in 64 bit mode.
You can run python in 32 bit mode using:
arch -i386 python2.6

iMac-TCWan:pyfantom tcmac$ arch -i386 python2.6 pyfantom.py
[...]

I presume that yo're talking about nxt-python. You should use version 2.2.1 or later. In adition, you should have a .nxt-python config file in your home directory.
$ cat ~/.nxt-python

Code: Select all

[Brick]
name = 
host = 
strict = 0
method = usb=False, bluetooth=False, fantomusb=True, fantombt=False
Note that FantomBT does not work for raw protocol messages (i.e. bypassing send direct command), I haven't managed to figure out why.
tcwan
Posts: 186
Joined: 30 Sep 2010, 07:39

Re: On Linux, linxt will upload any file except a .rxe [SOLVED]

Post by tcwan »

Hi John,
afanofosc wrote: I can provide an intel 32-bit binary of libfantom.so if anyone would like to experiment with it on Linux. It does require libusb 0.1.

John
Any reason why you're not using libusb 1.0.x? AFAIK libusb 0.1 uses blocking I/O, i.e., if you read from USB, it must receive something from the USB connection or else it'll block forever. There is no timeout.

There's also the issue of 32-bit vs. 64-bit libraries, most of my Linux systems are 64-bit; it's not a deal breaker, but it does require having to maintain two sets of libraries.
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: On Linux, linxt will upload any file except a .rxe [SOLVED]

Post by afanofosc »

I mention providing a 32-bit intel build simply because that's the sort of Linux I have readily available. You'd probably be better off building it yourself from my SVN repository. Just get from bricxcc using svn and make -ffantom.mak after you make sure that you have a recent build of FreePascal installed on your box.

I used libusb 0.1 since that is what I had when I wrote the code several years ago. I imagine that it could be converted to the newer version with some effort.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: On Linux, linxt will upload any file except a .rxe [SOLVED]

Post by afanofosc »

Would it be possible to release pyfantom under a dual license so that it could be used without requiring the GPL? If not I'll have to reimplement one from scratch which I'll release under MPL.

I'd like to get a python wrapper working under Linux using my libfantom.so.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
tcwan
Posts: 186
Joined: 30 Sep 2010, 07:39

Re: On Linux, linxt will upload any file except a .rxe [SOLVED]

Post by tcwan »

afanofosc wrote:Would it be possible to release pyfantom under a dual license so that it could be used without requiring the GPL? If not I'll have to reimplement one from scratch which I'll release under MPL.

I'd like to get a python wrapper working under Linux using my libfantom.so.

John Hansen
I'm fine with it, will need Nicolas Schodet's approval as well though.
(I'd rather only have to deal with one code base if at all possible.)
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests