Google Groups Home
Help | Sign in
RXTX on Windows and Bluetooth SPP doesn't work as expected
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Bruce Boyes  
View profile
 More options Jul 16, 7:20 pm
From: Bruce Boyes <bbo...@systronix.com>
Date: Wed, 16 Jul 2008 17:20:22 -0600
Local: Wed, Jul 16 2008 7:20 pm
Subject: RXTX on Windows and Bluetooth SPP doesn't work as expected
Hi

So I'm using RXTX on windows XP SP2 and talking to a Blue Soleil USB Bluetooth adapter with their software 5.2.227.1. Ultimately we want the PC app to control a robot with the remote Bluetooth adapter.
http://trackbot.systronix.com/bluetooth.html

If I use realterm to open a virtual COM25 port it automatically connects through the USB BT to a remote BT device (a Lemos Int LM-048). I can open and close the port as many times as I want to and the connection gets made and then disconnected as it should. So this tends to tell me that the USB BT adapter is OK and the Blue Soleil drivers seem to be working OK. RealTerm and the USB BT don't use RXTX as far as I know.

On the remote BT device I have it connected to another PC with RealTerm running. One of the BT adapters sends a CONNECT and DISCONNECT message at the appropriate times and I can see those on the remote PC RealTerm window. I can type data both ways.

However, when I try to use my own simple Java App on the PC, with RXTX to the virtual COM port, things fall apart.

BTW the same app on a cabled serial connection works fine, for millions of messages, with RXTX, so the problem doesn't appear to be in my serial code, or the RXTX comm package but in the use of BT or BT in combination with RXTX? That's what I can't yet figure out.

My Java code uses code like this to open the UART:

CommPortIdentifier cpi = CommPortIdentifier.getPortIdentifier(portName);
then
SerialPort serialPort = (SerialPort) cpi.open("TrackBot", 5000); // try-catch causes this to always fail!
then
in = serialPort.getInputStream(); // in a try-catch

With a clean powerup of the remote BT (Lemos LM-048), my Java code can open an input stream and write some data. But:

1) I see a CONNECT and then a DISCONNECT - but have no idea why the DISCONNECT happens. AFAIK my code isn't closing the COM port anywhere
2) then another CONNECT?? Why?
3) then my short app runs, sends some data to the COM port and it's transmitted over BT
4) then my app closes the serial port and terminates

If I try to run my app again, it reports that it got an instance of the UART (COM25, a virtual serial port from Bluetooth) but in fact there is no BT connection made. How is this possible?

I have to power cycle the Lemos LM-048 adapter in order to get my code to run again. The adapter takes 45 seconds to power up! This also seems strange.

And finally, if I put the cpi.open() in a try-catch block like this:
      try {
        SerialPort serialPort = (SerialPort) cpi.open("TrackBot", 5000);
        } catch (Exception piue) {
                  System.out.println(portName + " exception: " + piue.getMessage());
                  piue.printStackTrace();
        }
if (null == serialPort) {
         System.out .println("Error! " + getClass().getName()
        + " can't get Serial Port " + portName);
        System. exit(2);
        } else {
         System.out .println(getClass().getName() + " got Serial Port " + portName);
        }

The Exception is never thrown, but the value of serialPort is null so I see the message. If I take the open() out of the try-catch, serialPort is not null. I'm baffled.

Can anyone shed some light on this?

I'm going to write a simpler test program using javaxcomm and see if it acts differently, and then try it with RXTX as well as with a wired connection for both javaxcomm and rxtx.

best regards

Bruce

------- WWW.SYSTRONIX.COM ----------
  Real embedded Java and much more
+1-801-534-1017  Salt Lake City, USA


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
grudolph  
View profile
 More options Jul 16, 9:13 pm
From: grudolph <george.rudo...@gmail.com>
Date: Wed, 16 Jul 2008 18:13:16 -0700 (PDT)
Local: Wed, Jul 16 2008 9:13 pm
Subject: Re: RXTX on Windows and Bluetooth SPP doesn't work as expected
Bruce,
I can't shed light on your problem myself,
but I would suggest talking to the Lejos NXT people
Brian Bagnall or Lawrie Griffiths, and maybe browsing
the Lejos iCommand code would help.
You probably alreeady know this, but iCommand is Java
code that runs on the PC but lets you control an NXT brick
via Bluetooth.
They had previously run into similar problems, and
solved them, I think, using Bluecove libraries.

George

On Jul 16, 7:20 pm, Bruce Boyes <bbo...@systronix.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google