コード例 #1
0
        protected bool RunSingleReadableCommand(IReadableCommand aCommand)
        {
            try
            {
                //_communicatorInstance.ReadTimeout = 2000;
                _communicatorInstance.FlushBuffer();

                _communicatorInstance.WriteLine(aCommand.ReadParamsCommand());

                string        zAnswerLine = "";
                List <string> zAnswerList = new List <string>();

                while (!BaseATCommand.CheckCommandAnswer(zAnswerLine))
                {
                    zAnswerLine = _communicatorInstance.ReadLine();
                    zAnswerList.Add(zAnswerLine);
                }

                _logger.Debug("Correct Answer received. Try to parse it");
                return(aCommand.Parse(zAnswerList));
            }
            catch (Exception zException)
            {
                _logger.WarnException("Failed Single command run", zException);
                return(false);
            }
        }
コード例 #2
0
        protected bool RunSingleWritableCommand(IWritableCommand aCommand)
        {
            try
            {
                //_communicatorInstance.ReadTimeout = 2000;
                _communicatorInstance.FlushBuffer();

                _communicatorInstance.WriteLine(aCommand.WriteCommand());

                string zAnswerLine = "";
                bool   zResult     = false;
                while (!BaseATCommand.CheckCommandAnswer(zAnswerLine))
                {
                    zAnswerLine = _communicatorInstance.ReadLine();
                    zResult     = zResult || BaseATCommand.PositiveAnswer(zAnswerLine);
                }

                _logger.Debug("Correct Answer received OK");
                return(zResult);
            }
            catch (Exception zException)
            {
                _logger.WarnException("Failed Single command run", zException);
                return(false);
            }
        }
コード例 #3
0
        protected virtual bool DeviceWakeUp()
        {
            _logger.Debug("Try to Device wake up");
            try
            {
                _communicatorInstance.WriteLine("AT");

                string zAnswer = "";
                while (!BaseATCommand.PositiveAnswer(zAnswer))
                {
                    zAnswer = _communicatorInstance.ReadLine();
                }

                _logger.Debug("Device wake up OK");
                return(true);
            }
            catch (Exception zException)
            {
                _logger.WarnException("Failed Device wake up", zException);
                return(false);
            }
        }