/// <summary> /// Tries to parse an alternative memory status response of the CPMS command. /// </summary> /// <param name="input">A response to the +CPMS set command</param> /// <returns>A <see cref="T:GsmComm.GsmCommunication.MessageMemoryStatus" /> object containing the status information of the storages /// if successful, otherwise null.</returns> private MessageMemoryStatus TryParseMessageMemoryStatus2(string input) { MessageMemoryStatus messageMemoryStatu = null; Regex regex = new Regex("\\+CPMS: \"(\\w+)\",(\\d+),(\\d+),\"(\\w+)\",(\\d+),(\\d+)(?:,\"(\\w+)\",(\\d+),(\\d+))?"); Match match = regex.Match(input); if (match.Success) { messageMemoryStatu = new MessageMemoryStatus(); string value = match.Groups[1].Value; int num = int.Parse(match.Groups[2].Value); int num1 = int.Parse(match.Groups[3].Value); string str = match.Groups[4].Value; int num2 = int.Parse(match.Groups[5].Value); int num3 = int.Parse(match.Groups[6].Value); messageMemoryStatu.ReadStorage = new MemoryStatusWithStorage(value, num, num1); messageMemoryStatu.WriteStorage = new MemoryStatusWithStorage(str, num2, num3); if (match.Groups[7].Captures.Count > 0) { string value1 = match.Groups[7].Value; int num4 = int.Parse(match.Groups[8].Value); int num5 = int.Parse(match.Groups[9].Value); messageMemoryStatu.ReceiveStorage = new MemoryStatusWithStorage(value1, num4, num5); } } return messageMemoryStatu; }
/// <summary> /// Parses the memory status response of the CPMS command. /// </summary> /// <param name="input">A response to the +CPMS set command</param> /// <returns>A <see cref="T:GsmComm.GsmCommunication.MessageMemoryStatus" /> object containing the status information of the storages.</returns> /// <remarks> /// <para>Data for the ReceiveStorage (mem3) or for the WriteStorage (mem2) is null if there is no information available about it.</para> /// </remarks> private MessageMemoryStatus ParseMessageMemoryStatus(string input) { MessageMemoryStatus messageMemoryStatu; Regex regex = new Regex("\\+CPMS: (\\d+),(\\d+)(?:,(\\d+),(\\d+))?(?:,(\\d+),(\\d+))?"); Match match = regex.Match(input); if (!match.Success) { messageMemoryStatu = this.TryParseMessageMemoryStatus2(input); if (messageMemoryStatu == null) { this.HandleCommError(input); return null; } } else { messageMemoryStatu = new MessageMemoryStatus(); int num = int.Parse(match.Groups[1].Value); int num1 = int.Parse(match.Groups[2].Value); messageMemoryStatu.ReadStorage = new MemoryStatus(num, num1); if (match.Groups[3].Captures.Count > 0 && match.Groups[4].Captures.Count > 0) { int num2 = int.Parse(match.Groups[3].Value); int num3 = int.Parse(match.Groups[4].Value); messageMemoryStatu.WriteStorage = new MemoryStatus(num2, num3); } if (match.Groups[5].Captures.Count > 0 && match.Groups[6].Captures.Count > 0) { int num4 = int.Parse(match.Groups[5].Value); int num5 = int.Parse(match.Groups[6].Value); messageMemoryStatu.ReceiveStorage = new MemoryStatus(num4, num5); } } return messageMemoryStatu; }