私は Windows Seven 64 ビットを使用しています。RXTX
シリアルポートを介した通信に使用する小さなアプリケーションを作成しました。Windows 64 ビット版を使用しrxtxSerial.dll
ましたが、Eclispe と NetBeans の両方でうまく動作します。
プロジェクトのルートにRXTXComm.jar
、rxtxSerial.dll.
アプリケーションをデプロイするときに問題が発生します。Eclipse でエクスポート機能を使用したか、NetBeans から bin/ フォルダーにアクセスしました。フォルダーのルートに再度配置しRXTXComm.jar
ましrxtxSerial.dll
たが、Application.jar を実行すると、RXTX
機能していないようです。スキャンは 1 秒以上続くべきではありませんが、スタックしたままのようです。
[申し訳ありませんが、「画像を投稿するには少なくとも 10 の評判が必要です。」]
インターネットで見つけたすべての提案を試しました。
- dll と RXTXComm.jar を JRE フォルダーにインストールする
- DLLをWindows32フォルダーに配置する
- Export from Eclipseのさまざまなエクスポートオプションをすべて試しました
私は何かが欠けているに違いない。RXTX
Windows 32/64bit および MAC への展開に成功した人はいますか? 何をしたか、そのために何が必要かを説明していただけますか?
ポートのスキャン時に実行されるコードを以下に示します。
private void scanButtonAction()
{
if(scanState == ST_FREE)
{
scanState = ST_SCANNING;
redrawComponents();
scan = new Thread(new ScanPorts());
scan.start();
}
}
// Thread run to scan the ports
private class ScanPorts implements Runnable {
public void run()
{
try
{
UARTConnection connection = new UARTConnection();
// listPort() is a long blocking call
String[][] list = connection.listPorts();
// Display the ports in the ComboBox
comboBoxModel.removeAllElements();
if(list.length == 0) comboBoxModel.addElement( new Item(-1, "No port scanned", "" ) );
else
{
for(int i = 0; i < list.length; i++)
{
// Id, Description (user's display), PortName (for serial connection)
comboBoxModel.addElement( new Item(i, list[i][1], list[i][0]) );
}
// To select the first item of the list. Necessary with custom Rendered
portNumberBox.setSelectedIndex(0);
}
scanState = ST_FREE;
redrawComponents();
// The connect button is enabled only after a first scan
connectButton.setEnabled(true);
}
catch(Exception ex)
{
scanState = ST_FREE;
redrawComponents();
}
}
}
public class UARTConnection {
public UARTConnection()
{
}
public String[][] listPorts() throws Exception
{
Enumeration<CommPortIdentifier> portEnum = CommPortIdentifier.getPortIdentifiers();
Enumeration<CommPortIdentifier> tmpPortEnum = portEnum;
ArrayList<String[]> list = new ArrayList<String[]>();
int i = 0;
while ( portEnum.hasMoreElements() )
{
String port[] = new String[2];
CommPortIdentifier portIdentifier = portEnum.nextElement();
System.out.println(portIdentifier.getName() + " - " + getPortTypeName(portIdentifier.getPortType()));
port[0] = portIdentifier.getName();
port[1] = portIdentifier.getName() + " - " + getPortTypeName(portIdentifier.getPortType());
list.add(port);
i++;
}
String listOfPort[][] = new String[list.size()][2];
for(i = 0; i < list.size(); i++)
{
String[] port = list.get(i);
listOfPort[i][0] = port[0];
listOfPort[i][1] = port[1];
}
return listOfPort;
}
private String getPortTypeName ( int portType )
{
switch ( portType )
{
case CommPortIdentifier.PORT_I2C:
return "I2C";
case CommPortIdentifier.PORT_PARALLEL:
return "Parallel";
case CommPortIdentifier.PORT_RAW:
return "Raw";
case CommPortIdentifier.PORT_RS485:
return "RS485";
case CommPortIdentifier.PORT_SERIAL:
return "Serial";
default:
return "unknown type";
}
}
}
ご協力ありがとうございました。