Beispiel #1
0
        /// <summary>
        /// Establish blade serial session over Serial
        /// </summary>
        private void EstablishBladeSerialSessionOverSerialClient()
        {
            // start the read on another thread.
            Thread receiver = new Thread(new ThreadStart(Receive));
            receiver.Start();

            // Read continually until activeRead signal escapes.
            while (SharedFunc.ActiveSerialSession)
            {
                // This method blocks. Get user input and send it to the blade
                Byte[] userEnteredData = CliSerialPort.ReadUserInputBytesFromSerial();
                // Check if the data has ctrl-c and exit 
                for (int i = 0; i < userEnteredData.Length; i++)
                {
                    // Snoop to see if the user entered Ctrl+C 
                    if ((int)userEnteredData[i] == 3)
                    {
                        // Signal the receive thread to stop
                        SharedFunc.SetSerialSession(false);

                        // Stop the serial session
                        StopBladeSerialSession stopCmd = new StopBladeSerialSession();
                        stopCmd.isSerialClient = true;
                        stopCmd.argVal.Add('i', bladeId);
                        stopCmd.commandImplementation();

                        // Display that serial session has ended
                        Console.WriteLine("Blade serial session ended..\n");
                        break;
                    }
                }
                Send(userEnteredData);
            }
        }