6
$\begingroup$

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?

$\endgroup$
3
  • 1
    $\begingroup$ 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 $\endgroup$
    – andre314
    Apr 23, 2013 at 7:27
  • $\begingroup$ @andre I tried this but unfortunately it did no difference. I got it to work however, see my answer :) $\endgroup$
    – norq
    Apr 23, 2013 at 18:28
  • $\begingroup$ 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. $\endgroup$
    – Szabolcs
    Apr 23, 2013 at 18:39

1 Answer 1

1
$\begingroup$

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.

$\endgroup$
7
  • 1
    $\begingroup$ 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. $\endgroup$
    – Szabolcs
    Apr 23, 2013 at 18:37
  • $\begingroup$ 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. $\endgroup$
    – norq
    Apr 23, 2013 at 18:55
  • 1
    $\begingroup$ 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. $\endgroup$
    – Szabolcs
    Apr 23, 2013 at 18:56
  • $\begingroup$ @Szabolcs Just tested this and using $Link = Install["/Applications/Mathematica.app/AddOns/ExtraPackages/SerialIO/MacOSX/SerialIO"] just seem to hang evaluation but running SerialIO standalone displays the "Create Link: " prompt. $\endgroup$
    – norq
    Apr 24, 2013 at 19:37
  • 2
    $\begingroup$ 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. $\endgroup$
    – ragfield
    Apr 24, 2013 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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