Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int index = 0;
- port = new SerialPort();
- port.BaudRate = 115200;
- port.DataBits = 8;
- port.StopBits = StopBits.One;
- port.Parity = Parity.None;
- port.ReadTimeout = 300;
- port.WriteTimeout = 300;
- port.RtsEnable = true;
- port.DtrEnable = true;
- port.PortName = "COM11";
- port.Handshake = Handshake.RequestToSend;
- port.Open();
- port.DiscardOutBuffer();
- port.DiscardInBuffer();
- port.Write("ATrn"); // значит Внимание! для модема
- System.Threading.Thread.Sleep(300);
- Console.WriteLine("AT" + port.ReadExisting());
- port.Write("AT+CMGF=0rn"); // устанавливается текстовый режим для отправки сообщений
- System.Threading.Thread.Sleep(300);
- Console.WriteLine("AT+CMGF=0" + port.ReadExisting());
- foreach (string item in a)
- {
- var len = Convert.ToInt32(StringType.FromDouble(((double)a[index].Length - Conversion.Val("&H" + Strings.Mid(a[index], 1, 2)) * 2.0 - 2.0) / 2.0));
- Console.WriteLine(len);
- port.Write("AT+CMGS=" + len + "rn");
- System.Threading.Thread.Sleep(300);
- Console.WriteLine("AT+CMGS=" + len + port.ReadExisting());
- Console.WriteLine(item);
- port.Write(item + (char)26 + "rn");
- System.Threading.Thread.Sleep(3000);
- Console.WriteLine("SMS " + port.ReadExisting());
- index++;
- }
- port.Close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement