सुप्रभात,RXTX सूचीबद्ध कर सकते हैं नहीं या खिड़कियों के नीचे बंदरगाहों को खोजने के 7 64 बिट्स
मैं मुद्दों का उपयोग कर आ रही हैं/या विंडोज 7 64 बिट्स पर rxtx स्थापित करने। मैंने पहले x86 जीत XP सिस्टम पर इसके साथ काम किया था और इसमें कोई समस्या नहीं थी। किसी कारण से इस नई प्रणाली को पुनर्स्थापित करने के बाद से rxtx किसी भी बंदरगाहों को ढूंढने में असमर्थ है। मैंने rxtx इंस्टॉल, क्लाउड हूपर की 64 बिट देशी लाइब्रेरी और सभी rxtx फ़ाइलों को हटाने और स्क्रैच से शुरू करने का प्रयास किया है। RXTXcomm.jar पाया जाता है और मैं NetBeans में संकुल ब्राउज़ कर सकता हूं लेकिन कार्यान्वयन टूटा या पाया नहीं जाता है।
इस लाइन में विफल रहता है जब, हर बार क्रियान्वित:
comPort = "COM1";
portId = CommPortIdentifier.getPortIdentifier(comPort);
और एक NoSuchPortException फेंकता है।
इसका उपयोग कर धारावाहिक बंदरगाहों को सूचीबद्ध करने से कुछ भी नहीं पैदा होता है।
Enumeration ports = CommPortIdentifier.getPortIdentifiers();
String portArray[] = null;
while (ports.hasMoreElements()) {
CommPortIdentifier port = (CommPortIdentifier) ports.nextElement();
System.out.println(port.getName());
}
मैं देख लिया है सीरियल पोर्ट उपलब्ध हैं तो इस बिंदु पर मैं अगर देशी पुस्तकालयों बस विंडोज 7 64 बिट्स के लिए टूट रहे हैं सोच रहा हूँ।
क्या किसी ने विंडोज 7 64 बिट्स के तहत सफलतापूर्वक RXTX 2.2pre2 का उपयोग किया है? निर्माता में
अपमानजनक कोड अनुभाग:
public SerialControl(String name, String comPort, int baudrate, int databits, String parity, double stopbits) throws Exception {
int stop = 0;
int data = 0;
int par = 0;
this.name=name;
// Sanity checks and interpretation
if (baudrate > 115200 || baudrate < 300) {
System.err.println(name+": constructor(): Invalid baudrate "+baudrate);
throw new Exception("Invalid baudrate, " + baudrate);
}
if (databits >= 5 && databits <= 8) {
switch (databits) {
case 5:
data = SerialPort.DATABITS_5;
break;
case 6:
data = SerialPort.DATABITS_6;
break;
case 7:
data = SerialPort.DATABITS_7;
break;
case 8:
data = SerialPort.DATABITS_8;
break;
default:
System.err.println(name+": constructor(): Invalid data bits, switched " + databits);
throw new Exception("Invalid data bits, switched " + databits);
}
} else {
throw new Exception("Invalid data bits=" + databits);
}
if (stopbits >= 1.0 && stopbits <= 2.0) {
if (stopbits == 1.0) {
stop = SerialPort.STOPBITS_1;
} else if (stopbits == 1.5) {
stop = SerialPort.STOPBITS_1_5;
} else if (stopbits == 2.0) {
stop = SerialPort.STOPBITS_2;
} else {
System.err.println(name+": constructor(): Invalid stop bits, switched " + stopbits);
throw new Exception("Invalid stop bits, switched " + stopbits);
}
} else {
System.err.println(name+": constructor(): Invalid stop bits, switched " + stopbits);
throw new Exception("Invalid stop bits " + stopbits);
}
switch (parity) {
case "S":
par = SerialPort.PARITY_SPACE;
break;
case "E":
par = SerialPort.PARITY_EVEN;
break;
case "M":
par = SerialPort.PARITY_MARK;
break;
case "O":
par = SerialPort.PARITY_ODD;
break;
case "N":
par = SerialPort.PARITY_NONE;
break;
default:
System.err.println(name+": constructor(): Invalid parity, switched " + parity);
throw new Exception("Invalid parity, switched " + parity);
}
// Inits
// Try to find the port specified
try {
portId = CommPortIdentifier.getPortIdentifier(comPort);
} catch (Exception e) {
System.err.println(name+": constructor(): No such port \"" + comPort+"\"");
e.printStackTrace();
throw e;
}
// Open the port
try {
serialPort = (SerialPort) portId.open("User Port", 2000);
} catch (PortInUseException e) {
System.err.println(name+": constructor(): Could not open port " + comPort);
throw e;
}
// Grab the input stream
try {
inputStream = serialPort.getInputStream();
} catch (IOException e) {
System.err.println(name+": constructor(): Could not get input stream for " + comPort);
throw e;
}
// Set the serial port parameters, no flow control
try {
serialPort.setSerialPortParams(baudrate, data, stop, par);
serialPort.setDTR(false);
serialPort.setRTS(false);
} catch (UnsupportedCommOperationException e) {
System.err.println(name+": constructor(): Error initializing " + comPort);
throw e;
}
}
दोनों 'सीरियल कंट्रोल' और कमपोर्ट इंडेंटिफायर # getPortIdentifiers() 'ग्रहण से प्राप्त करें और कमांड लाइन – GrahamA
उन लोगों के लिए एक छोटा सा फॉलोअप जो इसे सामना कर सकते हैं, मेरी परियोजनाओं को विंडोज एक्सपी पर्यावरण से आयात किया गया था, विंडोज 7 में उन्हें पुनर्निर्माण करना प्रतीत होता है जो भी समस्या थी उसे सही किया। – darkhelmet