Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm following a guide from The Mathematica Journal that describes how to use Mathematica with the Lego Mindstorms NXT but have some trouble getting started and got stuck with the SerialIO package.

I use Mac OSX and I have installed the package to:

/Applications/Mathematica.app/AddOns/ExtraPackages/SerialIO/

The command Needs["SerialIO`"] gives me the following error message:

LinkOpen::linke: Could not find MathLink executable.

And trying

SetDirectory[FileNameJoin[{$InstallationDirectory, "AddOns", "ExtraPackages", "SerialIO", $SystemID}]];

Does not help either, it gives:

SetDirectory::cdir: Cannot set current directory to /Applications/Mathematica.app/AddOns/ExtraPackages/SerialIO/MacOSX-x86-64.

There seem to be some problem with the alias/symbolic link in the SerialIO folder. By default they pointed to an absolute directory on the machine that this library was built on:

MacOSX-x86-64 -> /Files/schofield/Packages/SerialIO/Build/Mac/build/Deployment/Package/SerialIO/MacOSX

I tried deleting the alias and creating a symbolic link in the terminal:

# ln -s MacOSX MacOSX-x86-64

Running the SetDirectory command again result in... no result, so I guess thats good. The commands seem to have been loaded as when typing Serial it want to autocomplete to SerialOpen etc.

However, using the command mybrick = SerialOpen["NXT"] does not put the NXT in connected mode (<> on NXT display). Does anyone else got it to work?

share|improve this question
1  
I think I had the same problem on windows. The solution was to move the file SerialIO.exe in the same directory as init.m –  andre Apr 23 '13 at 7:27
    
@andre I tried this but unfortunately it did no difference. I got it to work however, see my answer :) –  ihatetoregister Apr 23 '13 at 18:28
    
try changing Install["SerialIO"] to have the full path to the SerialIO executable. Also try runing the executable alone in a terminal and make sure it gives you the "create link" prompt. –  Szabolcs Apr 23 '13 at 18:39

1 Answer 1

up vote 1 down vote accepted

I finally got it to work with a little help of this and a git hub repo of the SerialIO package.

The problem was the line $Link = Install["SerialIO"] in init.m. This seem to only be valid on Windows so I changed this to the suggested $Link = Install["SerialIO", LinkProtocol->"Pipes"] and it now works.

Also, the mybrick = SerialOpen["/dev/tty.NXT"] had to include the full path to the serial port.

OSX aliases did not work either. I had to create a symbolic link alternatively create a "MacOSX-x86-64" folder with the SerialIO application to make it work.

share|improve this answer
1  
This is very unusual. Install["executablename"] is valid on all platforms. The preferred link type is the default shared memory one, not pipes. I'm not sure why only pipes worked with this package. –  Szabolcs Apr 23 '13 at 18:37
    
It might have to do with that it reads the serial port as a file (/dev/tty.Portname). Just guessing :) Forgot to add that I had to change this too so I have updated the answer. –  ihatetoregister Apr 23 '13 at 18:55
1  
It is unrelated to that. There should be no difference regardless of what the program that you Install actually does. That option specifies how Mathematica will communicate with the external program (the underlying protocol of MathLink). Try the suggestion from my other comment: include the full path of the external program and also see what it does if you run it standalone. –  Szabolcs Apr 23 '13 at 18:56
    
@Szabolcs Just tested this and using $Link = Install["/Applications/Mathematica.app/AddOns/ExtraPackages/SerialIO/MacOSX/Seri‌​alIO"] just seem to hang evaluation but running SerialIO standalone displays the "Create Link: " prompt. –  ihatetoregister Apr 24 '13 at 19:37
2  
I'm glad you got it working. The precompiled version available for download is quite out of date. The reason LinkProtocol->"Pipes" is necessary with the older version is due to an incompatibility between the v6 MathLink and v7,8,9. –  ragfield Apr 24 '13 at 20:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.