Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
2 ratings:
 3 out of 5     Rate this Document

Options for Using the LabWindows/CVI ComCallback with Serial Interfaces

Primary Software: LabWindows/CVI Development Systems>>Full Development System
Primary Software Version: 7.0
Primary Software Fixed Version: N/A
Secondary Software: N/A
Hardware: Serial

Problem: I am using the ComCallback in LabWindows/CVI to access a serial port. There are three different Event Masks for the InstallComCallback function call: LWRS_RXCHAR, LWRS_RXFLAG, and LWRS_RECEIVE. These Event Masks are used to specify the events that will cause this callback to occur. The events are based on data available at the serial port buffer. When I use each of these Event Masks I see different behavior. What does each Event Mask do?

Solution: 1. Using LWRS_RXCHAR above 2400 Baud
This event is set when any character appears in the input queue. The LWRS_RXCHAR callback function can receive more than one event at once and does not cause a separate callback for every byte received in the input queue. National Instruments recommends using LWRS_RXFLAG or LWRS_RECEIVE instead of LWRS_RXCHAR for baud rates higher than approximately 2400 baud.

2. Using LWRS_FLAG When an Event Occurs without Bytes in the Queue
The Event Mask LWRS_FLAG is set to respond when the EventCharacter is available in the queue. Occasionally Event ComCallback is called, but there are no bytes in the queue. This happens because LabWindows/CVI uses a Windows message internally to call the callback. The callback may be called when there are no bytes in the input queue, even though there were bytes in the queue at the time the message was posted. For this reason, it is recommended to check the input queue size before performing any operation in the callback.

3. Using LWRS_RECEIVE
With Event Mask set as LWRS_RECEIVE, the callback is set to detect when at least as many bytes as specified by notifyCount are available in the input queue. Once this event has occurred, it does not trigger again until the input queue falls below and then rises back above notifyCount bytes.


Related Links:

Attachments:





Report Date: 08/29/2003
Last Updated: 05/28/2004
Document ID: 30S7BKBS

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit