Skip to content

Instantly share code, notes, and snippets.

@OberdanBrito
Created June 25, 2020 10:20
Show Gist options
  • Save OberdanBrito/4633f22a23560982c4729568481e065e to your computer and use it in GitHub Desktop.
Save OberdanBrito/4633f22a23560982c4729568481e065e to your computer and use it in GitHub Desktop.
static void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Console.WriteLine($"Serial recebido");
string RxString = _serialPort.ReadExisting();
string SerialID;
if (RxString.IndexOf("\r\n") > -1 || RxString.IndexOf("|") > -1)
{
SerialID = RxString.Replace("\r\n", "").Replace("|", "");
Console.WriteLine($"Serial: {SerialID}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment