Saturday, April 26, 2008

RXTX and the funky PortInUseException on Macosx

I am using the RXTX serial libs for getting data out of my gps. They always worked nice, but the first time I tried them on Macosx they didn't work, throwing this ugly:

gnu.io.PortInUseException: Unknown Application

Since the thing worked from commandline:
>>> cat /dev/tty.touchGPS-SSP-1
$GPGGA,172025.233,2500.0001,N,12159.9999,E,0,0,,80.9,M,16.1,M,,*7D
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,1,1,00*79
$GPRMC,172025.233,V,2500.0001,N,12159.9999,E,0.00,0.00,260408,,,N*77
$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32... etc etc

I was pretty helpless. Then I found in some mailinglist archive the solution. To cite the guy that solved my problem: "As I've discovered the PortInUseException rarely has anything to do the port being in use. For reasons I don't understand RXTX is not using /var/spool/uucp for lock files. It's using /var/lock. A directory that didn't exist on my system. Once I created this directory I started getting different errors for the RXTX code. This directory requires read/write permissions for the user. I just used the blanket chmod 777."


Nothing to add, tried it and it worked.






UPDATE as of Saturday 4th of April 2009:


As a nice anonymous user comments, these are the steps to go:
  1. Open 'Terminal' from Applications->Utilities
  2. Enter the commands:
sudo mkdir /var/lock   (hit enter end type your password)
sudo chmod 777 /var/lock (hit enter again)

Post a Comment