Link to home
Start Free TrialLog in
Avatar of PaulVinten
PaulVinten

asked on

VM randomly crashes whilst using bluecove

Ok, I'm using the latest version of bluecove, and java 1.5 (v6). The following code seems to randomly cause the following error. It's very strange, sometimes the code will run for 40 loops with no problems, sometimes it will crash on the first one... it's really starting to bug me, and it sorting out asap...

Anyway

<a href="http://www.pvba13764.pwp.blueyonder.co.uk/hs_err_pid2004.log">Log file of crash</a>

Code:

import javax.bluetooth.LocalDevice;
import javax.bluetooth.*;
import java.util.Vector;
import java.io.*; /**

 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class BTH extends Thread{
  public static void main(String[] args) {
  BTH phas = new BTH();


}


  Vector<RemoteDevice> devices = new Vector();

  private
      LocalDevice BTAdapter;
  DiscoveryAgent BTDA;

  public BTH() {
    try {
      BTAdapter = LocalDevice.getLocalDevice();
      start();
    }
    catch (BluetoothStateException ex) {
      ex.printStackTrace();
    }

  }

  public void run()
  {
          int counter=0;
    while(true)
    {

      Search();
      counter++;
      System.out.println(counter + " Successful Searches");
      try {
        this.currentThread().sleep(60000);
      }
      catch (InterruptedException ex) {
      }
    }
  }
  public void Search() {
    devices.clear();

    System.out.println("Searching for devices...");
    BTDA = BTAdapter.getDiscoveryAgent();
    try {
      BTDA.startInquiry(DiscoveryAgent.GIAC, new Listener());
    }
    catch (BluetoothStateException ex) {
    }

  }




  class Listener
      implements DiscoveryListener {

    public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) {

      try {
        System.out.println("Device discovered:" + btDevice.getFriendlyName(false));
        devices.add(btDevice);
      }
      catch (IOException ex) {
      }

    }

    public void servicesDiscovered(int transID, ServiceRecord[] servRecord) {
    }

    public void serviceSearchCompleted(int transID, int respCode) {

    }

    public void inquiryCompleted(int discType) {
      System.out.println("\nFound " + devices.size() + " devices");

      for (RemoteDevice aDevice : devices) {
        try {
          System.out.println(aDevice.getBluetoothAddress() + "\t" +
                             aDevice.getFriendlyName(false));
        }
        catch(IOException ex)
        {

        }
      }

    }

  }
}


Any thoughts? What does the error code actually mean? and is there any way that I can simply ignore the error, reboot the affected bit and carry on, in real time?
Avatar of PaulVinten
PaulVinten

ASKER

D'oh, it doesn't support html tags. Never mind lol
Avatar of CEHJ
Try another version of bluecove - it's probably an internal error
Tried that, the only other version I could find just crashed it full stop
This turns out to be a semi-known bug with the deviceDiscovered function, it is buggy when used with the friendly name function. I've got conflicting information whether or not it's the bluecove or an inherrant problem with bluetooth itself. The solution is just to use the inquiryCompleted function.
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial