problens when try close firmata connection

edited April 2015 in Arduino

i am trying make a aplication capable of change between different arduino boards. But before a start a new connection i must close the previous one and i can't find correct whay to do this.

this is my code to connect:

public boolean tentarInstancia(String serial)
{
    try
    {
        //it's work with regular serial communication, but don't work with firmata
        arduino.stop();
    }

    catch (Exception e){println(e.getMessage());}

    finally{this.conectado = false;}

    try
    {
        arduino = new Arduino(dad, serial, 57600);

        delay(2000);

        try
        {
            definirModosPortas();   
        }
        catch (Exception e) {println(e.getMessage());}

        println("conexao com: " + serial + " bem sucedida");
        this.conectado = true;      
    }

    catch (Exception e){println(e.getMessage());}

    finally
    {
        if(conectado) this.COM = serial;
        else this.COM = "null";
        return this.conectado;
    }
}

Answers

Sign In or Register to comment.