System.IO.Ports.SerialPort.ReadExisting C# (CSharp) Méthode

ReadExisting() public méthode

public ReadExisting ( ) : string
Résultat string
		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));
		}

Usage Example

 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();
     }
 }
All Usage Examples Of System.IO.Ports.SerialPort::ReadExisting