We help IT Professionals succeed at work.

VM randomly crashes whilst using bluecove

PaulVinten
PaulVinten asked
on
Medium Priority
195 Views
Last Modified: 2010-07-27
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?
Comment
Watch Question

Author

Commented:
D'oh, it doesn't support html tags. Never mind lol
CERTIFIED EXPERT
Top Expert 2016

Commented:
Try another version of bluecove - it's probably an internal error

Author

Commented:
Tried that, the only other version I could find just crashed it full stop

Author

Commented:
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.
Commented:
PAQed with points refunded (125)

GranMod
Community Support Moderator

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.