public string ReadExisting () { CheckOpen (); int count = BytesToRead; byte [] bytes = new byte [count]; int n = stream.Read (bytes, 0, count); return new String (encoding.GetChars (bytes, 0, n)); }
public static string SMSDevice_Status(string comPort) { SerialPort port = new SerialPort(); String operatorString = "Error"; try { port.PortName = comPort; if (!port.IsOpen) { port.Open(); } port.WriteLine("AT+CREG?\r"); Thread.Sleep(2000); operatorString = port.ReadExisting(); return operatorString; } catch { return operatorString; } finally { port.Close(); } }