![](/img/trans.png)
[英]CommPortIdentifier.getPortIdentifier(portname) throughing exception
[英]CommPortIdentifier.getPortIdentifier() crashes program
我有一些適用於Windows 7的代碼但是當我在Windows 10機器上嘗試相同的代碼時程序關閉。 這是代碼:
try {
CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier((String)openParameters[0]);
this._serCommPort = (SerialPort) portId.open("PTxCore", 1000);
this._serCommPort.setSerialPortParams((int)openParameters[1], (int)openParameters[2], SerialPort.STOPBITS_1, (int)openParameters[3]);
this._serCommPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
this._serCommPort.addEventListener(this);
this._serCommPort.notifyOnDataAvailable(true);
this._commsOutStream = this._serCommPort.getOutputStream();
this._commsInStream = this._serCommPort.getInputStream();
this.clearBuffer();
this.onTraceEvent(TraceEventArgs.Mode.Hidden, "{Open}");
}
catch (UnsupportedCommOperationException | TooManyListenersException | IOException | PortInUseException | NoSuchPortException ex) {
throw new PTxCoreException(ex.getMessage(), ex.getClass().getName());
}
}
沒有例外被捕獲,它只是關閉。 我嘗試了不同版本的Eclipse(32/64位),並在Web上無處不在,但無法找到解決方案。 有什么想法可能會發生這種情況嗎? Serialio.jar(我認為處理這個?)顯然與Windows 10兼容。
當它關閉時我得到這個錯誤:
...的javaw.exe
還有這個東西在Eclipse的底部:
javax.comm.SerialPort implementation: version 3.8
Copyright (c) 1998-2009 Serialio.com, All Rights Reserved.
Serialio Library: version 10.1.2: build 9221
Copyright (c) 1996-2012 Serialio.com, All Rights Reserved.
os.name="Windows 10" os.arch="x86"
osName=Windows 10 osArch=x86
Platform not supported, check VM properties os.name & os.arch
它有點遲到,但它可能對某人有所幫助。 我得到了同樣的錯誤。 這是因為我使用的是舊版本的Serialio.jar。 將它升級到最新版本(我認為版本:9233?)后,它開始在Windows 10上正常運行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.