Handle Errors and Unrecognized Messages in LabVIEW Queued Message Handler Template

Updated Aug 3, 2023

Environment

Software

  • LabVIEW

This article is part of the Queued Message Handling series. Refer to the Queued Message Handling (QMH) overview documentation for general information on the QMH architecture.

It is important to keep your Queued Message Handler (QMH) application flexible enough to handle messages that you did not plan for and also robust enough to handle errors that you can foresee coming. If your QHM program allows user input to send messages, there are chances that you will receive unrecognized messages that you do not have a defined case to handle. Alternatively, you may receive errors in your program that you are aware of and want to ignore to avoid stopping the application. 

In this tutorial, you will design flexibility and robustness into your QMH. This tutorial utilizes the Queued Message Handler LabVIEW template. This an advanced LabVIEW architecture and this tutorial assumes knowledge with basic programming practices. 

Handling Unrecognized Messages

When designing a Queued Message Handler (QMH) that takes in multiple inputs, there is the chance that you receive messages that do not map to a designated case. To avoid producing errors, ensure all Case structures in an MHL have a Default message diagram. The code in the Default message diagram executes when the MHL reads a message that does not have a corresponding message diagram. Having a Default message diagram is important because messages are strings that are entered while programming or during UI, not values you select from an enum.
 

Ignoring Errors when Reading from the Message Queue

  1. From the Project Explorer window, open Message Queue.lvlib:Dequeue Message.vi and display the block diagram.
  2. Find the Case structure nested inside the Error case
  3. To ignore errors when reading from the message queue, add error codes to the case selector label of the nested Case structure.
    • The errors to ignore depend on your application. For example, if you are reading the queue over a network, you might want to ignore timeout errors.