/** * Determine the OS and where the OS has the devices located */ public void initialize() { if (debug) System.out.println("RXTXCommDriver:initialize()"); osName = System.getProperty("os.name"); deviceDirectory = getDeviceDirectory(); /* * First try to register ports specified in the properties file. If that doesn't exist, then scan for ports. */ for (int PortType = CommPortIdentifier.PORT_SERIAL; PortType <= CommPortIdentifier.PORT_PARALLEL; PortType++) { if (!registerSpecifiedPorts(PortType)) { if (!registerKnownPorts(PortType)) { registerScannedPorts(PortType); } } } }
String ValidPortPrefixes[]=new String [getScannedBufferSize()]; if (debug) System.out.println("\nRXTXCommDriver:getValidPortPrefixes()"); if(isPortPrefixValid(CandidatePortPrefixes[j])) { ValidPortPrefixes[i++]= CandidatePortPrefixes[j];
private void addSpecifiedPorts(String names, int PortType) { final String pathSep = System.getProperty("path.separator", ":"); final StringTokenizer tok = new StringTokenizer(names, pathSep); if (debug) System.out.println("\nRXTXCommDriver:addSpecifiedPorts()"); while (tok.hasMoreElements()) { String PortName = tok.nextToken(); if (testRead(PortName, PortType)) CommPortIdentifier.addPortName(PortName, PortType, this); } }
private void registerScannedPorts(int PortType) deviceDirectory=getDeviceDirectory(); String[] CandidateDeviceNames; if (debug) if (isClassPresent("com.sun.jna.platform.win32.Advapi32Util")) { temp = windowsGetSerialPortsFromRegistry(); performTestRead = false; // disable the testRead to simply add the port to the CommPortIdentifier index useFallback = false; temp = new String[getScannedBufferSize() + 3]; for (int i = 1; i <= getScannedBufferSize(); i++) { temp[i - 1] = "COM" + i; temp[i + getScannedBufferSize() - 1] = "LPT" + i; System.out.println("Unknown PortType "+PortType+" passed to RXTXCommDriver.registerScannedPorts()"); registerValidPorts(CandidateDeviceNames, CandidatePortPrefixes, PortType, performTestRead);
checkSolaris(PortName, PortType); else if (testRead(PortName, PortType)) { CommPortIdentifier.addPortName(PortName, PortType, this);
addSpecifiedPorts(val, PortType); return true; } else return false;
public static Set<String> getAvailableSerialPorts() { Set<String> available = new HashSet<String>(); try { RXTXCommDriver d = new RXTXCommDriver(); Set<String> av = d.getPortIdentifiers(); ArrayList<String> strs = new ArrayList<String>(); for (String s : av) { strs.add(0, s); } for (String s : strs) { available.add(s); } } catch (UnsatisfiedLinkError e) { e.printStackTrace(); throw new NativeResourceException(e.getMessage()); } return available; }
public Set<String> getPortIdentifiers() { ports =new HashSet<String>(); registerScannedPorts(CommPortIdentifier.PORT_SERIAL); Enumeration<CommPortIdentifier> pe; try{
if (isPortPrefixValid(CandidatePortPrefixes[j])) { ValidPortPrefixes[i++] = CandidatePortPrefixes[j];
RXTXCommDriver RXTXDriver = new RXTXCommDriver(); RXTXDriver.initialize();
System.out.println("Unknown PortType " + PortType + " passed to RXTXCommDriver.registerScannedPorts()"); registerValidPorts(CandidateDeviceNames, CandidatePortPrefixes, PortType);
private void registerScannedPorts(int PortType) deviceDirectory=getDeviceDirectory(); String[] CandidateDeviceNames; if (debug) if (isClassPresent("com.sun.jna.platform.win32.Advapi32Util")) { temp = windowsGetSerialPortsFromRegistry(); performTestRead = false; // disable the testRead to simply add the port to the CommPortIdentifier index useFallback = false; temp = new String[getScannedBufferSize() + 3]; for (int i = 1; i <= getScannedBufferSize(); i++) { temp[i - 1] = "COM" + i; temp[i + getScannedBufferSize() - 1] = "LPT" + i; System.out.println("Unknown PortType "+PortType+" passed to RXTXCommDriver.registerScannedPorts()"); registerValidPorts(CandidateDeviceNames, CandidatePortPrefixes, PortType, performTestRead);
checkSolaris(PortName,PortType); else if (testRead(PortName, PortType))
addSpecifiedPorts(val, PortType); return true; } else {
public static Set<String> getAvailableSerialPorts() { Set<String> available = new HashSet<String>(); try { RXTXCommDriver d = new RXTXCommDriver(); Set<String> av = d.getPortIdentifiers(); ArrayList<String> strs = new ArrayList<String>(); for (String s : av) { strs.add(0, s); } for (String s : strs) { available.add(s); } } catch (UnsatisfiedLinkError e) { e.printStackTrace(); throw new NativeResourceException(e.getMessage()); } return available; }
public Set<String> getPortIdentifiers() { ports =new HashSet<String>(); registerScannedPorts(CommPortIdentifier.PORT_SERIAL); Enumeration<CommPortIdentifier> pe; try{
if(isPortPrefixValid(CandidatePortPrefixes[j])) { ValidPortPrefixes[i++]= new String(CandidatePortPrefixes[j]);
RXTXCommDriver RXTXDriver = new RXTXCommDriver(); RXTXDriver.initialize();
System.out.println("Unknown PortType "+PortType+" passed to RXTXCommDriver.registerScannedPorts()"); registerValidPorts(CandidateDeviceNames, CandidatePortPrefixes, PortType);
/** * Determine the OS and where the OS has the devices located */ public void initialize() { if (debug) System.out.println("RXTXCommDriver:initialize()"); osName=System.getProperty("os.name"); deviceDirectory=getDeviceDirectory(); /* First try to register ports specified in the properties file. If that doesn't exist, then scan for ports. */ if (!registerSpecifiedPorts(CommPortIdentifier.PORT_SERIAL)) { if (!registerKnownPorts(CommPortIdentifier.PORT_SERIAL)) { registerScannedPorts(CommPortIdentifier.PORT_SERIAL); } } }