예제 #1
0
 public string WaitingData(int timeout, string ResultContain = null, string Error = "")
 {
     receive_AutoResponse.Reset();
     try
     {
         string result = "";
         do
         {
             if (receive_AutoResponse.WaitOne(timeout, false))
             {
                 string t = SpGSM_Modem_AutoResponse.ReadExisting();
                 result += t;
             }
             else
             {
                 string t = SpGSM_Modem_AutoResponse.ReadExisting();
                 result += t;
                 return(result);
             }
         }while ((!result.EndsWith("\r\nOK\r\n") && !result.EndsWith("\r\n> ") && !result.EndsWith("\r\nERROR\r\n") && !result.EndsWith("\r\n") && !result.EndsWith("\r")) &&
                 ((ResultContain != null && result.Contains(ResultContain)) || ResultContain == null));
         return(result);
     }
     catch (Exception ex)
     {
         LoggingData.WriteLog(ex);
         return(string.Empty);
     }
 }
예제 #2
0
 public string ExecuteCommands(string ATcommand, int timeout, string Error = "")
 {
     receiveNow.Reset();
     try
     {
         string result = "";
         SpGSM_Modem.Write(ATcommand + "\r");
         do
         {
             if (receiveNow.WaitOne(timeout, false))
             {
                 string t = SpGSM_Modem.ReadExisting();
                 result += t;
             }
             else
             {
                 string t = SpGSM_Modem.ReadExisting();
                 result += t;
                 return(result);
             }
         }while (!result.EndsWith("\r\nOK\r\n") && !result.EndsWith("\r\n> ") && !result.EndsWith("\r\nERROR\r\n"));
         return(result);
     }
     catch (Exception ex)
     {
         LoggingData.WriteLog(ex);
         return(ex.Message);
     }
 }