AForge.Robotics.Lego.NXTBrick.Connect C# (CSharp) Метод

Connect() публичный Метод

Connect to NXT brick.
If connection to NXT brick was established before the call, existing connection will be reused. If it is required to force reconnection, then Disconnect method should be called before.
public Connect ( string portName ) : bool
portName string Serial port name to use for communication, for example COM1.
Результат bool
        public bool Connect( string portName )
        {
            lock ( sync )
            {
                if ( communicationInterface != null )
                    return true;

                // create communication interface,
                communicationInterface = new SerialCommunication( portName );
                // connect and check if NXT is alive
                if ( ( communicationInterface.Connect( ) ) && ( IsAlive( ) ) )
                    return true;

                Disconnect( );
            }
            return false;
        }