I have a rev B (Core 2 Duo from Dec, 2006) Apple MacBook Pro laptop running Leopard OS X (version 10.5.2) and have Matlab version 126.96.36.1998 (R2007b). I’ve just found that I can NOT use the built-in serial port object, instead, I get the following error:
java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver ??? Error using ==> serial.serial at 57 The serial port object is supported on the Solaris, 32-bit Windows and 32-bit Linux platforms only.
So, to get it successfully working, I downloaded these files: SerialComm.m, SerialComm.mexmac and SerialComm.mexmaci from http://svn.berlios.de/svnroot/repos/osxptb/stable/Psychtoolbox/PsychHardware/.
You can then use code like this:
PORT = 1; % close (if previously open) SerialComm( 'close', PORT) % open SerialComm('open',PORT,'9600,n,8,1') % flush the buffers SerialComm( 'purge', PORT) % status SerialComm( 'status', PORT) % read STR = SerialComm( 'readl', PORT); % close SerialComm( 'close', PORT)
[UPDATE 02 Apr, 2008]: Note, this same code didn’t seem to work on a recently purchased Macbook. Good luck.
[UPDATE 27 Mar, 2009]: I see that in Matlab version 7.8.0 (R2009a) if you go to ‘serial’ in Help docs it now says for Mac OS X and Mac OS X 64 you can use serial(‘/dev/tty.KeySerial1’); I don’t have a way of testing that right now, but it’s possible that you don’t need to use this third party toolkit anymore. If that’s true, please leave a note here.