2012-08-12 300 views
0

我有一个按钮,这个代码,当我按下它,我得到的错误:连接失败[10048]

Error: Exception connecting to NXT. 
    Caused by lejos.pc.comm.NXTCommException: Open of NXT failed. 
at lejos.pc.comm.NXTCommBluecove.open(NXTCommBluecove.java:136) 
    Caused by javax.bluetooth.BluetoothConnectionException: Failed to connect; [10048] 
Only one usage of each socket address (protocol/network address/port) is normally permitted. 
at com.intel.bluetooth.BluetoothStackMicrosoft.connect(Native Method) 
Failed to connect to any NXT 

我张贴,因为它工作正常,但昨日似乎没有被工作今天。

btnConnectBot.addActionListener(new ActionListener() { 

     public void actionPerformed(ActionEvent e) { 
      if (Cnt1){ 
       try { 
        conn.close(); 
        Cnt1=!Cnt1; 
        txtConnState.setText("Off"); 
        txtConnState.setForeground(Color.RED); 
       } catch (IOException e1) { 
        // TODO Auto-generated catch block 
        e1.printStackTrace(); 
       } 
      } 
      else{ 
       conn.addLogListener(new NXTCommLogListener() { 
       public void logEvent(String message) { 
       System.out.println(message); 
       } 

       public void logEvent(Throwable throwable) { 
       System.err.println(throwable.getMessage()); 
       } 
       }); 
       conn.setDebug(true); 
       if (!conn.connectTo(txtBotName.getText(), NXTComm.LCP)) { 
       System.err.println("Fallo de conexión"); 
       txtConnState.setText("Off"); 
       txtConnState.setForeground(Color.RED); 
       System.exit(1); 
       } 
       Cnt1=!Cnt1;  
       txtConnState.setText("On"); 
       txtConnState.setForeground(Color.GREEN); 

       if (chckbxLock_2.isSelected()){ 
        btnConnectBot_2.doClick(); 
       } 
       if (chckbxLock_1.isSelected()){ 
        btnConnectBot_1.doClick(); 
       } 
      } 
     } 
    }); 

根据我的研究,这是因为正在使用的蓝牙端口正在被多个实例访问。但是我不明白这个代码是如何发生的。

回答

0

您是否为远程设备配置了蓝牙虚拟COM端口?也许它是由一些程序打开的...

或者,错误是否在您第一次运行程序时发生?是否有任何运行程序的旧副本 - check in taskmgr.exe