Reply To: How to handle when a brick is turned off & back on?

HomeForumsMonoBrick Communication LibraryHow to handle when a brick is turned off & back on?Reply To: How to handle when a brick is turned off & back on?

#3758
Author Image
Mike O’C
Participant

Not quite in place; the “GenericBrick.cs” class has a constructor which doesn’t take a bool ‘isEv3′, but tries to automatically detect whether a brick is NXT or EV3. This also has not worked yet. I tried updating it to do a similar thing to the ‘resetConnection()’ method, but so far no luck:

public GenericBrick(string newBrickName, string newConnName)
{
    brickName = newBrickName + "";
    connName = newConnName + "";
    state = STATE_NEW;

    // first, try to connect as if it is an NXT
    connectToBrick(false, true);
    if (state == STATE_NXT)
        return;

    // not a found NXT?
    if (nxtBrick != null)
    {
        if (nxtBrick.Connection != null)
            nxtBrick.Connection.Close();
    }
    nxtBrick = null;

    // try to connect as if it is an EV3
    connectToBrick(true, true);
}

However, in the meantime I wrote the Winforms UI to pop a dialog box asking if a brick is EV3 or NXT. That will work for the near term.

Attachments:
You must be logged in to view attached files.
Posted in

Make a donation