Hi,i have a fix for the SerialPortHelper.cs in the fonction SerialPort_MessageReceived
the textmessage is droped if the textMessage not contain the textEndOfLine
private void SerialPort_MessageReceived(object sender, MessageReceivedEventArgs args)
{
if (dataReceived != null)
{
dataReceived(args.Data);
}
if (stringReceived != null)
{
string textMessage = textBuffer + Encoding.UTF8.GetString(args.Data);
if (String.IsNullOrEmpty(textEndOfLine[0]))
{
// raw string receive
try { stringReceived(textMessage); } catch { }
}
else
{
// text line based string receive
textBuffer = "";
if (textMessage.Contains(textEndOfLine[0]))
{
string[] lines = textMessage.Split(textEndOfLine, StringSplitOptions.RemoveEmptyEntries);
for (int l = 0; l < lines.Length - (textMessage.EndsWith(textEndOfLine[0]) ? 0 : 1); l++)
{
try { stringReceived(lines[l]); } catch { }
}
if (!textMessage.EndsWith(textEndOfLine[0]))
{
textBuffer = lines[lines.Length - 1];
}
}
else
{
textBuffer = textMessage;
}
}
}
}
Hi,i have a fix for the SerialPortHelper.cs in the fonction SerialPort_MessageReceived the textmessage is droped if the textMessage not contain the textEndOfLine
private void SerialPort_MessageReceived(object sender, MessageReceivedEventArgs args) { if (dataReceived != null) { dataReceived(args.Data); } if (stringReceived != null) { string textMessage = textBuffer + Encoding.UTF8.GetString(args.Data); if (String.IsNullOrEmpty(textEndOfLine[0])) { // raw string receive try { stringReceived(textMessage); } catch { } } else { // text line based string receive textBuffer = ""; if (textMessage.Contains(textEndOfLine[0])) { string[] lines = textMessage.Split(textEndOfLine, StringSplitOptions.RemoveEmptyEntries); for (int l = 0; l < lines.Length - (textMessage.EndsWith(textEndOfLine[0]) ? 0 : 1); l++) { try { stringReceived(lines[l]); } catch { } } if (!textMessage.EndsWith(textEndOfLine[0])) { textBuffer = lines[lines.Length - 1]; } } else { textBuffer = textMessage; } } } }