robertoprato / bluecove

Automatically exported from code.google.com/p/bluecove
0 stars 0 forks source link

Strange behaviour under MacOSX #25

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use the sample application provided with the WiiRemoteJ Library
(WRLImpl.java)
2. First time after boot-up, the Wiimote will connect fine.
3. Close and re-run the application, the following exception will be thrown:

BlueCove version 2.0.2 on mac
14.01.2008 21:48:33 wiiremotej.WiiRemoteDiscoverer deviceDiscovered
FEIN: Nintendo RVL-CNT-01...
14.01.2008 21:48:33 wiiremotej.WiiRemoteDiscoverer deviceDiscovered
FEIN:  is a WiiRemote!
14.01.2008 21:48:34 wiiremotej.WiiRemote construct
INFO: btl2cap://00191DB47CCA
14.01.2008 21:48:36 wiiremotej.WiiRemote calibrateAccelerometer
FEINER: Calibrating accelerometer...
14.01.2008 21:48:36 wiiremotej.WiiRemote construct
FEINER: Initialization complete.
java.io.IOException: Error sending data!
   at wiiremotej.WiiRemote.sendCommand(WiiRemote.java:502)
   at wiiremotej.WiiRemote.setInputReport(WiiRemote.java:763)
   at wiiremotej.WiiRemote.setInputReport(WiiRemote.java:769)
   at wiiremotej.WiiRemote.setAccelerometerEnabled(WiiRemote.java:1451)
   at WRLImpl.main(WRLImpl.java:172)
Caused by: java.io.IOException: Connection closed
   at com.intel.bluetooth.BluetoothStackOSX.l2Send(Native Method)
   at
com.intel.bluetooth.BluetoothL2CAPConnection.send(BluetoothL2CAPConnection.java:
113)
   at wiiremotej.WiiRemote.sendCommand(WiiRemote.java:498)
   ... 4 more

What is the expected output? What do you see instead?
Suspected is that some commands are being sent to the Wiimote in order to
activate the IR-Sensor. Then constant readings from the sensor are expected.

What version of the product are you using? On what operating system?
2.0.2 on MacOSX 10.5.1

Please provide any additional information below.
The dev of the WiiRemoteJ has directed me here, so I hope you guys can help me.
If you need any additional information let me know.

Original issue reported on code.google.com by woodman...@gmail.com on 16 Jan 2008 at 9:36

GoogleCodeExporter commented 8 years ago
I just saw defect 23, and think they're related.
I'm using the release 2.0.2 of bluecove, should I try one of the newer builds?

Original comment by woodman...@gmail.com on 16 Jan 2008 at 10:04

GoogleCodeExporter commented 8 years ago
Can you please add system property -Dbluecove.debug=true and attach the result 
output
log file.

The defect 23 was fixed in release 2.0.2.

Also the problem is that apparently WiiRemote device is closing the L2CAP 
connection
on its end. The exception "IOException: Connection closed" indicates this.

If you run again "3. Close and re-run the application"  multiple times whats 
happening?

Original comment by skarzhev...@gmail.com on 16 Jan 2008 at 3:42

GoogleCodeExporter commented 8 years ago
Hi!

When I start the program several times in a row it eventually works.
Sometimes I need to restart ten times to get it working, other times it works 
two or
three times in a row.
I also found that the best way to close the program in terms of maximizing the 
chance
of it working again seems to be to disconnect the wiimote by pressing its 
connect button.
If I terminate the program manually it tends to not work more often, but it also
fails very often using the other method.

I'm currently at work so I cannot post a debug log right now, I'll try to 
upload one
this evening.

Thanks for your quick reply!

Original comment by woodman...@gmail.com on 17 Jan 2008 at 9:38

GoogleCodeExporter commented 8 years ago
As far as I can understand the problem is in WiiRemote application.
Since application is Closed Source I can't advise what is wrong with it.
As far as I can tell bluecove does not close open connection when application is
terminated. This may be a bug....
The best option is to try evaluation version of avetanaBluetooth and see if you 
have
the same problems.

Original comment by skarzhev...@gmail.com on 17 Jan 2008 at 4:40

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Hi!

Sorry for not answering for such a long time, but I became the father of two 
cute
little girls several days ago and therefore don't have too much free time on my 
hands
right now... ;)

I'll try it out with the avetana eval and let you know of the results...

OT: I received Mail that there was another reply to this thread, why can't I 
see it
here?!?

Original comment by woodman...@gmail.com on 1 Feb 2008 at 11:09

GoogleCodeExporter commented 8 years ago
Another problem was moved to this page:
http://code.google.com/p/bluecove/issues/detail?id=27
BTW it was resolved.

Congratulations on your family additions.

Original comment by skarzhev...@gmail.com on 1 Feb 2008 at 3:22

GoogleCodeExporter commented 8 years ago
I was having similar problems with WiiRemoteJ and bluecove. I think the problem 
is 
that the Wiimote only listens for a connection for a short time (maybe 15 
seconds), 
and then gives up. Sometimes it gives up right when WiiRemoteJ is trying to 
open a 
connection. Unfortunately the version of WiiRemoteJ I was using didn't fail 
gracefully when this happens, and instead assumes that the connection is open, 
when 
it isn't. This results in failures in sending data.

As a solution I went and wrote my own Wiimote library, which is very simple, 
but 
fails gracefully when a connection opening fails, and retries the connection 
opening 
until it works.

What would help this problem, either at the bluecove or possible driver level 
would 
be to look at why opening L2CAP connections can take so long. I know on my 
actual 
Nintendo Wii connections to the Wiimote are formed almost instantly, while 
connections to a Wiimote via bluecove can sometimes take 5 or 10 seconds, 
during 
which failure can occur.

Garth

Original comment by garth...@gmail.com on 9 Feb 2008 at 1:18

GoogleCodeExporter commented 8 years ago
By the way the above problems occured on both OS X and Windows platforms.

Original comment by garth...@gmail.com on 9 Feb 2008 at 1:20

GoogleCodeExporter commented 8 years ago
Actual Nintendo Wii does connect to Wiimote instantly because it remembers the
address of the Wiimote device. The WiiRemoteJ (Example app that I have seen) 
does
discovery all the time. Bluetooth discovery takes 5-10 seconds. WiiRemote is
discoverable and connectable only for 20 seconds since you pressed the 
buttons.....

So I think the WiiRemoteJ should be changed to work differently.

Original comment by skarzhev...@gmail.com on 9 Feb 2008 at 3:14

GoogleCodeExporter commented 8 years ago
Thank you for looking into this, I'll forward your replies to the WiiRemoteJ 
Developer.
Maybe he can fix this.

Cheers!

Original comment by woodman...@gmail.com on 12 Feb 2008 at 7:44

GoogleCodeExporter commented 8 years ago
I ran some tests (using bluecove-2.0.3-20080210.060324-26). I had absolutely 
zero problems when I waited 
5 seconds or so after calling the findRemote() method before making the Wii 
Remote discoverable (I think 
what is more relevant actually, is that it's about 1 or 2 seconds after devices 
start to be discovered, e.g. my 
phone). In these cases, the remote was detected almost immediately and 
proceeded to connect without 
problems. If I try before this time, it's a toss-up: sometimes it works; other 
times... not. I get two different 
types of errors, show below.

Error 1:

BlueCove version 2.0.3-SNAPSHOT on mac
Feb 12, 2008 6:29:49 PM wiiremotej.WiiRemoteDiscoverer deviceDiscovered
FINE: Found Nintendo RVL-CNT-01 (0017AB29BB7B)
Feb 12, 2008 6:29:49 PM wiiremotej.WiiRemoteDiscoverer deviceDiscovered
FINE: Nintendo RVL-CNT-01 is a WiiRemote.
Feb 12, 2008 6:29:50 PM wiiremotej.WiiRemote construct
INFO: btl2cap://0017AB29BB7B
Feb 12, 2008 6:29:51 PM wiiremotej.WiiRemoteDiscoverer getWiiRemote
SEVERE: Error getting device!
java.io.IOException: WiiRemote failed to connect!
    at wiiremotej.WiiRemote.construct(WiiRemote.java:290)
    at wiiremotej.WiiRemote.<init>(WiiRemote.java:214)
    at wiiremotej.WiiRemoteDiscoverer.getWiiRemote(WiiRemoteDiscoverer.java:94)
    at wiiremotej.WiiRemoteJ.findRemote(WiiRemoteJ.java:208)
    at wiiremotej.WiiRemoteJ.findRemote(WiiRemoteJ.java:186)
    at WRLImpl.main(WRLImpl.java:135)
Caused by: javax.bluetooth.BluetoothConnectionException: Failed to open 
connection(3)
    at com.intel.bluetooth.BluetoothStackOSX.l2OpenClientConnectionImpl(Native Method)
    at com.intel.bluetooth.BluetoothStackOSX.l2OpenClientConnection(BluetoothStackOSX.java:604)
    at com.intel.bluetooth.BluetoothL2CAPClientConnection.<init>(BluetoothL2CAPClientConnection.java:33)
    at com.intel.bluetooth.MicroeditionConnector.openImpl(MicroeditionConnector.java:397)
    at com.intel.bluetooth.MicroeditionConnector.open(MicroeditionConnector.java:506)
    at javax.microedition.io.Connector.open(Connector.java:95)
    at wiiremotej.WiiRemote.construct(WiiRemote.java:284)
    ... 5 more

Error 2:

BlueCove version 2.0.3-SNAPSHOT on mac
Feb 12, 2008 6:31:14 PM wiiremotej.WiiRemoteDiscoverer deviceDiscovered
FINE: Found Nintendo RVL-CNT-01 (0017AB29BB7B)
Feb 12, 2008 6:31:14 PM wiiremotej.WiiRemoteDiscoverer deviceDiscovered
FINE: Nintendo RVL-CNT-01 is a WiiRemote.
Feb 12, 2008 6:31:15 PM wiiremotej.WiiRemote construct
INFO: btl2cap://0017AB29BB7B
Feb 12, 2008 6:31:15 PM wiiremotej.WiiRemote calibrateAccelerometer
FINER: Calibrating accelerometer...
Feb 12, 2008 6:31:15 PM wiiremotej.WiiRemote calibrateAccelerometer
WARNING: Unable to calibrate accelerometer!
Feb 12, 2008 6:31:15 PM wiiremotej.WiiRemote construct
WARNING: Error calibrating accelerometer.
java.io.IOException: Error sending data!
    at wiiremotej.WiiRemote.sendCommand(WiiRemote.java:502)
    at wiiremotej.WiiRemote.readData(WiiRemote.java:1260)
    at wiiremotej.WiiRemote.readData(WiiRemote.java:1212)
    at wiiremotej.WiiRemote.calibrateAccelerometer(WiiRemote.java:1286)
    at wiiremotej.WiiRemote.construct(WiiRemote.java:479)
    at wiiremotej.WiiRemote.<init>(WiiRemote.java:214)
    at wiiremotej.WiiRemoteDiscoverer.getWiiRemote(WiiRemoteDiscoverer.java:94)
    at wiiremotej.WiiRemoteJ.findRemote(WiiRemoteJ.java:208)
    at wiiremotej.WiiRemoteJ.findRemote(WiiRemoteJ.java:186)
    at WRLImpl.main(WRLImpl.java:135)
Caused by: java.io.IOException: Failed to write [0xe00002bc]
    at com.intel.bluetooth.BluetoothStackOSX.l2Send(Native Method)
    at com.intel.bluetooth.BluetoothL2CAPConnection.send(BluetoothL2CAPConnection.java:113)
    at wiiremotej.WiiRemote.sendCommand(WiiRemote.java:498)
    ... 9 more
Feb 12, 2008 6:31:15 PM wiiremotej.WiiRemote construct
FINER: Initialization complete.
java.io.IOException: Error sending data!
    at wiiremotej.WiiRemote.sendCommand(WiiRemote.java:502)
    at wiiremotej.WiiRemote.setInputReport(WiiRemote.java:763)
    at wiiremotej.WiiRemote.setInputReport(WiiRemote.java:769)
    at wiiremotej.WiiRemote.setAccelerometerEnabled(WiiRemote.java:1451)
    at WRLImpl.main(WRLImpl.java:138)
Caused by: java.io.IOException: Connection closed
    at com.intel.bluetooth.BluetoothStackOSX.l2Send(Native Method)
    at com.intel.bluetooth.BluetoothL2CAPConnection.send(BluetoothL2CAPConnection.java:113)
    at wiiremotej.WiiRemote.sendCommand(WiiRemote.java:498)
    ... 4 more
Feb 12, 2008 6:31:24 PM wiiremotej.WiiRemote$1 run
FINE: Wii Remote disconnected.
Remote disconnected... Please Wii again.
BlueCove stack shutdown completed

In error 1 it simply fails to open a connection. It's interesting to note that 
with error 2, the read stream is still 
open, since it closes when the remote's disconnect button is held down. The 
write stream is closed, however, 
as indicated by the error. I'm not sure why this pause is necessary. I can tell 
you what WiiRemoteJ is doing and 
maybe you can tell me if there's anything wrong in there. I don't think 
anything I'm doing is outside of the 
API, though.

1. Someone calls findRemote()
2. findRemote makes sure no other find methods are running.
3. findRemote starts device inquiry via startInquiry(DiscoveryAgent.GIAC, 
discoverer) (using a discovery agent 
initialized in a static constructor for WiiRemoteJ)
4. findRemote waits until the inquiry ends (using wait() and a synchronized 
method).
5. In deviceDiscovered: deviceDiscovered checks that the remote isn't one of 
the remotes that was already 
found and connected.
6. deviceDiscovered saves the address of the remote.
6. deviceDiscovered cancels the inquiry.
7. As a result of the inquiry completing (being canceled), the thread running 
findRemote is notified and grabs 
the address of the remote from the discoverer and passes to the WiiRemote 
constructor.
8. The constructor opens two connections in this order:
sendCon = (L2CAPConnection)Connector.open(connectURL+":"+O_CHANNEL, 
Connector.WRITE);
receiveCon = (L2CAPConnection)Connector.open(connectURL+":"+I_CHANNEL, 
Connector.READ);
(O_CHANNEL = 11, I_CHANNEL = 13)
9. A listener is started that reads from the input stream.
10. A bunch of output is sent down the output stream. I can tell you the 
precise data if that will help.

If that's not helpful, I can send you some of the code.

P.S. garthubc, the problem is not with the remote not being connected fast 
enough. It's usually only 
discoverable for no more than 5 or 10 seconds before something happens. In 
addition, the connection 
definitely is open at some point because the remote successfully requests and 
receives calibration data for the 
accelerometer. After this, for an unknown reason, the output connection is 
closed (see error 2). In error 1, the 
connections are not opened and the program gracefully throws an exception.

Original comment by ctt...@gmail.com on 13 Feb 2008 at 12:22

GoogleCodeExporter commented 8 years ago
Hi,

I was seeing:

java.io.IOException: Error sending data!
    at wiiremotej.WiiRemote.sendCommand(WiiRemote.java:502)
    at wiiremotej.WiiRemote.setInputReport(WiiRemote.java:763)
    at wiiremotej.WiiRemote.setInputReport(WiiRemote.java:769)
    at wiiremotej.WiiRemote.setAccelerometerEnabled(WiiRemote.java:1451)
    at WRLImpl.main(WRLImpl.java:138)
Caused by: java.io.IOException: Connection closed
    at com.intel.bluetooth.BluetoothStackOSX.l2Send(Native Method)
    at com.intel.bluetooth.BluetoothL2CAPConnection.send(BluetoothL2CAPConnection.java:113)
    at wiiremotej.WiiRemote.sendCommand(WiiRemote.java:498)
    ... 4 more

but noticed two things:

1) the connection works (but not the output connection) so I can receive input 
from
the wiimote.

2) it seemed to work (even the output connection) when I held A and B 
simutaneaously.

The exact order was 1&2 on the remote, held A and B , started my java program to
discover the remote.

Shawn

Original comment by big.coffee.lover@gmail.com on 8 Nov 2008 at 3:58

GoogleCodeExporter commented 8 years ago
Hi, is anybody using the wiiremotej to interface with the wii balance board? i 
have tried and modified the sample code attached in this library but i always 
got error message. Here is the error:

28-Jun-2011 14:20:38 wiiremotej.WiiDeviceDiscoverer deviceDiscovered
FINE: Found <No Name> (0017AC006F84)
28-Jun-2011 14:20:39 wiiremotej.WiiDeviceDiscoverer deviceDiscovered
FINE: <No Name> is NOT a known device.

why and my program can only run once, i mean after the first time it is run, i 
will get no response when i try to run it second time. Thanks!

below is the code:

package summer.wiiboard;

/**
 *
 * @author Mat
 */

import java.awt.*;
import javax.swing.*;
import wiiremotej.*;
import wiiremotej.event.*;
import java.io.*;

public class BBImpl extends BalanceBoardAdapter
{
    private BalanceBoard board;
    private static JFrame graphFrame;
    private static JPanel graph;
    private static double massX;
    private static double massY;

    public static void main(String args[])
    {
        java.lang.System.setProperty("bluecove.jsr82.psm_minimum_off", "true");
        java.lang.System.setProperty("bluecove.stack.first", "widcomm");
        //basic console logging options...
        WiiRemoteJ.setConsoleLoggingAll();
        //WiiRemoteJ.setConsoleLoggingOff();
        try
        {
            graphFrame = new JFrame();
    //        graphFrame.setTitle("Mass Graph");
            graphFrame.setTitle("Center of gravity graph: Balance Board");
            graphFrame.setSize(800, 600);
            graphFrame.setResizable(false);

            graph = new JPanel()
            {
                public void paintComponent(Graphics graphics)
                {
                    graphics.clearRect(0, 0, 800, 600);
                    graphics.fillRect(0, 0, 800, 600);
                    graphics.setColor(Color.WHITE);
                    graphics.drawLine(0, 300, 800, 300);
                    graphics.drawLine(400, 0, 400, 600);

                    graphics.setColor(Color.RED);
                    graphics.fillOval((int)(massX * 800+400-15), (int)(massY * 600+300-15), 30, 30);
                }
            };

            graph.setDoubleBuffered(true);
            graphFrame.add(graph);
            graphFrame.setVisible(false);
            //Find and connect to a Balance Board
            BalanceBoard board = null;
            System.out.println("Please press the red syn button.");

            while (board == null) {
               try {
                    System.out.println("Trying to connect.");
                    board = WiiRemoteJ.findBalanceBoard();

               }
                    catch(Exception e) {
                    board = null;
                    e.printStackTrace();
                    System.out.println("Failed to connect board. Trying again.");
                }

           }

            System.out.println("Wii Balance Board is connected.");

            board.addBalanceBoardListener(new BBImpl(board));
            board.setLEDIlluminated(true);

            final BalanceBoard boardF = board;
            Runtime.getRuntime().addShutdownHook(new Thread(new Runnable(){public void run(){boardF.disconnect();}}));
        }
        catch(Exception e){e.printStackTrace();}
    }

    public BBImpl(BalanceBoard board)
    {
        this.board = board;
    }

    public void disconnected()
    {
        System.out.println("Board disconnected... Please Wii again.");
        System.exit(0);
    }

    public void massInputReceived(BBMassEvent evt)
    {
        double massTL = evt.getMass(MassConstants.TOP, MassConstants.LEFT);
        double massTR = evt.getMass(MassConstants.TOP, MassConstants.RIGHT);
        double massBL = evt.getMass(MassConstants.BOTTOM, MassConstants.LEFT);
        double massBR = evt.getMass(MassConstants.BOTTOM, MassConstants.RIGHT);

        if (evt.getTotalMass() > 3) { // if mass is too small, don't bother
            double topMass = massTL + massTR;
            double bottomMass = massBL + massBR;
            double leftMass = massTL + massBL;
            double rightMass = massTR + massBR;

            double vertRange = topMass + bottomMass;
            double horizRange = rightMass + leftMass;

            massX = (rightMass-leftMass)/horizRange;
            massY = -(topMass-bottomMass)/vertRange;
        }
        else {
            massX = 0;
            massY = 0;
        }

        graph.repaint();
    }

    public void buttonInputReceived(BBButtonEvent evt) {
        if (evt.wasPressed()) {
            System.out.println("Disconnecting! Please Wii again.");
            System.exit(0);
        }
    }

}

Original comment by changb...@gmail.com on 28 Jun 2011 at 1:39

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Hello. 
I had the same problem and I solved uninstalling the bluetooth stack from my OS 
and installing widcomm bluetooh stack.

You can follow this link to help:
http://forum.notebookreview.com/sony/114793-how-install-widcomm-bluetooth-stack-
v5-1-0-1100-xp-vista-sz.html

and download the widcomm stack from here:
http://search.4shared.com/postDownload/IkKlX58B/Widcomm_501801_bluetooth_drive.h
tml

good luck for all.

Original comment by heraldoc...@gmail.com on 3 Dec 2011 at 10:27