	private void registerScannedPorts(int PortType)
	{
		String[] CandidateDeviceNames;
		if (debug)
			System.out.println("scanning device directory "+deviceDirectory+" for ports of type "+PortType);
		if(osName.toLowerCase().indexOf("windows") != -1 )
		{
			String[] temp = { "COM1", "COM2","COM3","COM4" };
			CandidateDeviceNames=temp;
		}
		else if ( osName.equals("Solaris") || osName.equals("SunOS"))
		{
			String term[] = new String[2];
			int l = 0;
			File dev = null;
			dev = new File( "/dev/term" );
			if( dev.list().length > 0 );
				term[l++] = new String( "term/" );
			dev = new File( "/dev/cua0" );
			if( dev.list().length > 0 );
				term[l++] = new String( "cua/" );
			String[] temp = new String[l];
			for(l--;l >= 0;l--)
				temp[l] = term[l];
			CandidateDeviceNames=temp;
		}
		else
		{
			File dev = new File( deviceDirectory );
			String[] temp = dev.list();
			CandidateDeviceNames=temp;
		}
		if (CandidateDeviceNames==null)
		{
			if (debug)
				System.out.println("RXTXCommDriver:registerScannedPorts() no Device files to check ");
			return;
		}
		String CandidatePortPrefixes[] = {};
		switch (PortType) {
			case CommPortIdentifier.PORT_SERIAL:
				if (debug)
					System.out.println("scanning for serial ports for os "+osName);
				if(osName.equals("Linux"))
				{
					String[] Temp = {
					"ttyS" 
					};
					CandidatePortPrefixes=Temp;
				}
				else if(osName.equals("Linux-all-ports"))
				{
					String[] Temp = {
					"comx",      
					"holter",    
					"modem",     
					"ttyircomm", 
					"ttycosa0c", 
					"ttycosa1c", 
					"ttyC", 
					"ttyCH",
					"ttyD", 
					"ttyE", 
					"ttyF", 
					"ttyH", 
					"ttyI", 
					"ttyL", 
					"ttyM", 
					"ttyMX",
					"ttyP", 
					"ttyR", 
					"ttyS", 
					"ttySI",
					"ttySR",
					"ttyT", 
					"ttyUSB",
					"ttyV", 
					"ttyW", 
					"ttyX"  
					};
					CandidatePortPrefixes=Temp;
				}
				else if(osName.equals("Irix"))
				{
					String[] Temp = {
						"ttyc", 
						"ttyd", 
						"ttyf", 
						"ttym", 
						"ttyq", 
						"tty4d",
						"tty4f",
						"midi", 
						"us"    
					};
					CandidatePortPrefixes=Temp;
				}
				else if(osName.equals("FreeBSD")) 
				{
					String[] Temp = {
						"cuaa"  
					};
					CandidatePortPrefixes=Temp;
				}
				else if(osName.equals("NetBSD")) 
				{
					String[] Temp = {
						"tty0"  
					};
					CandidatePortPrefixes=Temp;
				}
				else if ( osName.equals("Solaris")
						|| osName.equals("SunOS"))
				{
					String[] Temp = {
						"term/",
						"cua/"
					};
					CandidatePortPrefixes=Temp;
				}
				else if(osName.equals("HP-UX"))
				{
					String[] Temp = {
						"tty0p",
						"tty1p" 
					};
					CandidatePortPrefixes=Temp;
				}
				else if(osName.equals("UnixWare") ||
						osName.equals("OpenUNIX"))
				{
					String[] Temp = {
						"tty00s", 
						"tty01s",
						"tty02s",
						"tty03s" 
					};
					CandidatePortPrefixes=Temp;
				}
			else if	(osName.equals("OpenServer"))
				{
					String[] Temp = {
						"tty1A",  
						"tty2A",
						"tty3A",
						"tty4A",
						"tty5A",
						"tty6A",
						"tty7A",
						"tty8A",
						"tty9A",
						"tty10A",
						"tty11A",
						"tty12A",
						"tty13A",
						"tty14A",
						"tty15A",
						"tty16A",
						"ttyu1A", 
						"ttyu2A",
						"ttyu3A",
						"ttyu4A",
						"ttyu5A",
						"ttyu6A",
						"ttyu7A",
						"ttyu8A",
						"ttyu9A",
						"ttyu10A",
						"ttyu11A",
						"ttyu12A",
						"ttyu13A",
						"ttyu14A",
						"ttyu15A",
						"ttyu16A"
					};
					CandidatePortPrefixes=Temp;
				}
				else if (osName.equals("Compaq's Digital UNIX"))
				{
					String[] Temp = {
						"tty0"  
					};
					CandidatePortPrefixes=Temp;
				}
				else if(osName.equals("BeOS"))
				{
					String[] Temp = {
						"serial" 
					};
					CandidatePortPrefixes=Temp;
				}
				else if(osName.equals("Mac OS X"))
				{
					String[] Temp = {
						"cu.KeyUSA28X191.",
						"tty.KeyUSA28X191.",
						"cu.KeyUSA28X181.",
						"tty.KeyUSA28X181.",
						"cu.KeyUSA19181.",
						"tty.KeyUSA19181."
					};
					CandidatePortPrefixes=Temp;
				}
				else if(osName.toLowerCase().indexOf("windows") != -1 )
				{
					String[] Temp = {
						"COM"    
					};
					CandidatePortPrefixes=Temp;
				}
				else
				{
					if (debug)
						System.out.println("No valid prefixes for serial ports have been entered for "+osName + " in RXTXCommDriver.java.  This may just be a typo in the method registerScanPorts().");
				}
				break;
			case CommPortIdentifier.PORT_PARALLEL:
				if (debug)
					System.out.println("scanning for parallel ports for os "+osName);
				if(osName.equals("Linux")
				)
				{
					String[] temp={
						"lp"    
					};
					CandidatePortPrefixes=temp;
				}
				else if(osName.equals("FreeBSD"))
				{
					String[] temp={
						"lpt"
					};
					CandidatePortPrefixes=temp;
				}
				else  
				{
					String [] temp={};
					CandidatePortPrefixes=temp;
				}
				break;
			default:
				if (debug)
					System.out.println("Unknown PortType "+PortType+" passed to RXTXCommDriver.registerScannedPorts()");
		}
		registerValidPorts(CandidateDeviceNames, CandidatePortPrefixes, PortType);
	}

	private void registerScannedPorts(int PortType)
	{
		String[] CandidateDeviceNames;
		if (debug)
			System.out.println("scanning device directory "+deviceDirectory+" for ports of type "+PortType);
		if(osName.toLowerCase().indexOf("windows") != -1 )
		{
			String[] temp = { "COM1", "COM2","COM3","COM4" };
			CandidateDeviceNames=temp;
		}
		else if ( osName.equals("Solaris") || osName.equals("SunOS"))
		{
			String term[] = new String[2];
			int l = 0;
			File dev = null;
			dev = new File( "/dev/term" );
			if( dev.list().length > 0 );
				term[l++] = new String( "term/" );
			dev = new File( "/dev/cua0" );
			if( dev.list().length > 0 );
				term[l++] = new String( "cua/" );
			String[] temp = new String[l];
			for(l--;l >= 0;l--)
				temp[l] = term[l];
			CandidateDeviceNames=temp;
		}
		else
		{
			File dev = new File( deviceDirectory );
			String[] temp = dev.list();
			CandidateDeviceNames=temp;
		}
		if (CandidateDeviceNames==null)
		{
			if (debug)
				System.out.println("RXTXCommDriver:registerScannedPorts() no Device files to check ");
			return;
		}
		String CandidatePortPrefixes[] = {};
		switch (PortType) {
			case CommPortIdentifier.PORT_SERIAL:
				if (debug)
					System.out.println("scanning for serial ports for os "+osName);
				if(osName.equals("Linux"))
				{
					String[] Temp = {
					"ttyS" 
					};
					CandidatePortPrefixes=Temp;
				}
				else if(osName.equals("Linux-all-ports"))
				{
					String[] Temp = {
					"comx",      
					"holter",    
					"modem",     
					"ttyircomm", 
					"ttycosa0c", 
					"ttycosa1c", 
					"ttyC", 
					"ttyCH",
					"ttyD", 
					"ttyE", 
					"ttyF", 
					"ttyH", 
					"ttyI", 
					"ttyL", 
					"ttyM", 
					"ttyMX",
					"ttyP", 
					"ttyR", 
					"ttyS", 
					"ttySI",
					"ttySR",
					"ttyT", 
					"ttyUSB",
					"ttyV", 
					"ttyW", 
					"ttyX"  
					};
					CandidatePortPrefixes=Temp;
				}
				else if(osName.equals("Irix"))
				{
					String[] Temp = {
						"ttyc", 
						"ttyd", 
						"ttyf", 
						"ttym", 
						"ttyq", 
						"tty4d",
						"tty4f",
						"midi", 
						"us"    
					};
					CandidatePortPrefixes=Temp;
				}
				else if(osName.equals("FreeBSD")) 
				{
					String[] Temp = {
						"cuaa"  
					};
					CandidatePortPrefixes=Temp;
				}
				else if(osName.equals("NetBSD")) 
				{
					String[] Temp = {
						"tty0"  
					};
					CandidatePortPrefixes=Temp;
				}
				else if ( osName.equals("Solaris")
						|| osName.equals("SunOS"))
				{
					String[] Temp = {
						"term/",
						"cua/"
					};
					CandidatePortPrefixes=Temp;
				}
				else if(osName.equals("HP-UX"))
				{
					String[] Temp = {
						"tty0p",
						"tty1p" 
					};
					CandidatePortPrefixes=Temp;
				}
				else if(osName.equals("UnixWare") ||
						osName.equals("OpenUNIX"))
				{
					String[] Temp = {
						"tty00s", 
						"tty01s",
						"tty02s",
						"tty03s" 
					};
					CandidatePortPrefixes=Temp;
				}
			else if	(osName.equals("OpenServer"))
				{
					String[] Temp = {
						"tty1A",  
						"tty2A",
						"tty3A",
						"tty4A",
						"tty5A",
						"tty6A",
						"tty7A",
						"tty8A",
						"tty9A",
						"tty10A",
						"tty11A",
						"tty12A",
						"tty13A",
						"tty14A",
						"tty15A",
						"tty16A",
						"ttyu1A", 
						"ttyu2A",
						"ttyu3A",
						"ttyu4A",
						"ttyu5A",
						"ttyu6A",
						"ttyu7A",
						"ttyu8A",
						"ttyu9A",
						"ttyu10A",
						"ttyu11A",
						"ttyu12A",
						"ttyu13A",
						"ttyu14A",
						"ttyu15A",
						"ttyu16A"
					};
					CandidatePortPrefixes=Temp;
				}
				else if (osName.equals("Compaq's Digital UNIX") || osName.equals("OSF1"))
				{
					String[] Temp = {
						"tty0"  
					};
					CandidatePortPrefixes=Temp;
				}
				else if(osName.equals("BeOS"))
				{
					String[] Temp = {
						"serial" 
					};
					CandidatePortPrefixes=Temp;
				}
				else if(osName.equals("Mac OS X"))
				{
					String[] Temp = {
						"cu.KeyUSA28X191.",
						"tty.KeyUSA28X191.",
						"cu.KeyUSA28X181.",
						"tty.KeyUSA28X181.",
						"cu.KeyUSA19181.",
						"tty.KeyUSA19181."
					};
					CandidatePortPrefixes=Temp;
				}
				else if(osName.toLowerCase().indexOf("windows") != -1 )
				{
					String[] Temp = {
						"COM"    
					};
					CandidatePortPrefixes=Temp;
				}
				else
				{
					if (debug)
						System.out.println("No valid prefixes for serial ports have been entered for "+osName + " in RXTXCommDriver.java.  This may just be a typo in the method registerScanPorts().");
				}
				break;
			case CommPortIdentifier.PORT_PARALLEL:
				if (debug)
					System.out.println("scanning for parallel ports for os "+osName);
				if(osName.equals("Linux")
				)
				{
					String[] temp={
						"lp"    
					};
					CandidatePortPrefixes=temp;
				}
				else if(osName.equals("FreeBSD"))
				{
					String[] temp={
						"lpt"
					};
					CandidatePortPrefixes=temp;
				}
				else  
				{
					String [] temp={};
					CandidatePortPrefixes=temp;
				}
				break;
			default:
				if (debug)
					System.out.println("Unknown PortType "+PortType+" passed to RXTXCommDriver.registerScannedPorts()");
		}
		registerValidPorts(CandidateDeviceNames, CandidatePortPrefixes, PortType);
	}
