async private Task <string> ReadResponse()
        {
            try
            {
                await Task.Delay(200).ConfigureAwait(false);

                string response = sp.ReadExisting();
                sp.Close();
                string[] responseArray = response.Split(',', '\r');

                if (responseArray[1] == "0")
                {
                    return("0");
                }
                else
                {
                    Protocol.ErrorCode _error = new Protocol.ErrorCode();
                    _error.NoErrorExists(response);
                    return(responseArray[1]);
                }
            }

            catch (IndexOutOfRangeException) { return("Illegal Response or No Response!"); }
            catch (Exception e) { return(e.Message); }
        }
Example #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Protocol.ErrorCode _errorCode = new Protocol.ErrorCode();
            string             _command   = TBCommand.Text + '\r';

            _errorCode.NoErrorExists(_command);
        }
        void sp_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            SerialPort sp       = sender as SerialPort;
            string     response = sp.ReadExisting();

            Protocol.ErrorCode _error = new Protocol.ErrorCode();
            if (!_error.NoErrorExists(response))
            {
                _listbox.Items.Add("Marking Finished!");
            }
        }