Home→Forums→MonoBrick Communication Library→How to handle when a brick is turned off & back on?→Reply To: How to handle when a brick is turned off & back on?
January 4, 2014 at 20:48
#3758

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.
Follow