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.LocalDevic e;
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("Search ing for devices...");
BTDA = BTAdapter.getDiscoveryAgen t();
try {
BTDA.startInquiry(Discover yAgent.GIA C, new Listener());
}
catch (BluetoothStateException ex) {
}
}
class Listener
implements DiscoveryListener {
public void deviceDiscovered(RemoteDev ice btDevice, DeviceClass cod) {
try {
System.out.println("Device discovered:" + btDevice.getFriendlyName(f alse));
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("\nFoun d " + devices.size() + " devices");
for (RemoteDevice aDevice : devices) {
try {
System.out.println(aDevice .getBlueto othAddress () + "\t" +
aDevice.getFriendlyName(fa lse));
}
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?
Anyway
<a href="http://www.pvba13764.pwp.blueyonder.co.uk/hs_err_pid2004.log">Log file of crash</a>
Code:
import javax.bluetooth.LocalDevic
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
try {
this.currentThread().sleep
}
catch (InterruptedException ex) {
}
}
}
public void Search() {
devices.clear();
System.out.println("Search
BTDA = BTAdapter.getDiscoveryAgen
try {
BTDA.startInquiry(Discover
}
catch (BluetoothStateException ex) {
}
}
class Listener
implements DiscoveryListener {
public void deviceDiscovered(RemoteDev
try {
System.out.println("Device
devices.add(btDevice);
}
catch (IOException ex) {
}
}
public void servicesDiscovered(int transID, ServiceRecord[] servRecord) {
}
public void serviceSearchCompleted(int
}
public void inquiryCompleted(int discType) {
System.out.println("\nFoun
for (RemoteDevice aDevice : devices) {
try {
System.out.println(aDevice
aDevice.getFriendlyName(fa
}
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?
Try another version of bluecove - it's probably an internal error
ASKER
Tried that, the only other version I could find just crashed it full stop
ASKER
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER