Overview
This code demonstrates how to add meta data to elements being sent through a queue in a producer consumer
Description
While methods such as the use of variants can allow the developer to transmit any information they wish via queues or similar systems, it can also be useful to be able to append additional information to an element which can then be deconstructed on the consumer side and processed.
This example has example use cases in real-time systems using DMA FIFOs, where single elements are transmitted/received between target and host.
To add the additional meta data to an element, the queue must first be configured to have sufficient bit-width to host the additional information. In this example, where our actual information is 16-bit information and our meta data is a 16-bit numerical identifier, this means configuring the queue to hold a 32-bit integer.
To append the meta data to the channel data, we use the Join Numbers function, and to separate the data we use the Split Number Function.
Examples of where this may be useful would be the transmission of encoder information, where both the magnitude of the speed and the direction of the encoder could be sent together. This example could be expanded/altered to also enable us to send a channel identifier if multiple encoders were being used (for e.g. 16-bit for actual data, 8-bit for direction and 8-bit for channel identifier).
Requirements
Steps to Implement or Execute Code
Additional Information or References
Front Panel
VI Block Diagram
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.