a few possibilities come to my mind...

You may need to wait longer for things to settle before reopening
the port. Or the port/driver itself may be wedged. I have that trouble
with my current USB->serial converter and have to unplug the cable
to get it to cooperate.

SF may not be closing the serial port correctly when you stopDetecting().
You could try setting sf = null and doing gc(). That might make a finalizer
run someplace. Then you need to create a new sf of course.

It's not clear to me if the javax.comm lib is very smart about closing
ports. So it might just-not-work(TM). You may need to kill the entire
process running sf to get it cleaned up.

It might be easier to construct your app as a script that starts SF
in the background and then runs your foreground program...or...if
everything is running locally anyway, just use direct serial access
in your program.

MS


Javier . wrote:
Hi, I'm trying to use SerialForwarder in my aplication, but Iwant to do it invisible to the user. Is not dificult to start listening to the serial port with the "-no-gui" option. The problem begins when I stop SerialForwarder listening to the port. If I try to start listening again, this advise apears:

[EMAIL PROTECTED]:57600 died - restarting (java.io.IOException: Port COM3 busy)
SF enabled, 1 client, 0 packets read, 0 packets written SF enabled, 1 client, 0 packets read, 0 packets written SF enabled, 1 client, 0 packets read, 0 packets written

SF disabled, 1 client, 0 packets read, 0 packets written

Followed by this error message:

java.io.IOException: Port COM3 busy
at net.tinyos.packet.SerialByteSource.openStreams(SerialByteSource.java:69)
    at net.tinyos.packet.StreamByteSource.open(StreamByteSource.java:51)
at net.tinyos.packet.Packetizer.openSource(Packetizer.java:119).........

This is my code:

    public synchronized void startDetecting(){
        if (sf==null){
            try {
sf = new SerialForwarder(new String[] {"-quiet","-no-gui","-comm","[EMAIL PROTECTED]"+serialPort+":mica2","-port","9001"});
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        else{
            sf.startListenServer();
        }
        waitingForConnection = new Vector(0);
        moteif = new MoteIF(PrintStreamMessenger.err);
        moteif.registerListener(new ConnectionMsg(),this);
        detecting=true;
    }

    public synchronized void stopDetecting(){
        moteif.deregisterListener(new ConnectionMsg(),this);
        sf.listenServerStopped
        sf.stopListenServer();
        detecting=false;
    }

I'm using the 1.1.15 CVS version.
The only thing I want is to have a variable called sf of the type SerialForwarder in order to start and stop listening when the user wants but without the SerialForwarder gui.

Thanks in advance.


_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to