Adds try/catch to Communication_BytesReceived callback to prevent exception from getting logged when malformed message is received

This commit is contained in:
Neil Dorin
2020-01-16 16:40:02 -07:00
parent 47f4d90c5a
commit 1017464980

View File

@@ -166,6 +166,8 @@ namespace PepperDash.Essentials.Devices.Displays
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
void Communication_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs e) void Communication_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs e)
{
try
{ {
// This is probably not thread-safe buffering // This is probably not thread-safe buffering
// Append the incoming bytes with whatever is in the buffer // Append the incoming bytes with whatever is in the buffer
@@ -246,6 +248,11 @@ namespace PepperDash.Essentials.Devices.Displays
// Save whatever partial message is here // Save whatever partial message is here
IncomingBuffer = newBytes; IncomingBuffer = newBytes;
} }
catch (Exception err)
{
Debug.Console(2, this, "Error parsing feedback: {0}", err);
}
}
/// <summary> /// <summary>
/// ///