ncWaitForState.vi

NI-CAN

ncWaitForState.vi

Purpose

Wait for one or more states to occur in an object.

Format

Input

ObjHandle in is the object handle from the previous NI-CAN VI. The handle originates from the ncOpen VI.

DesiredState specifies a bit mask of states for which notification is desired. You can use a single state alone, or you can OR them together:

00000001 hex Read Available

At least one frame is available, which you can obtain using an appropriate read VI.

The state is set whenever a frame arrives for the object. The state is cleared when the read queue is empty.

00000002 hex Write Success

All frames provided through write VIs have been successfully transmitted onto the network. Successful transmit means that the frame won arbitration, and was acknowledged by a remote device.

The state is set when the last frame in the write queue is transmitted successfully. The state is cleared when a write VI is called.

When communication starts, the Write Success state is true by default.

For CAN, write success means that the frame won arbitration, and was acknowledged by a remote device. For LIN, write success means that the frame was successfully processed by the LIN interface.

00000008 hex Read Multiple

A specified number of frames are available, which you can obtain using either ncReadNetMult or ncReadObjMult. The number of frames is configured using the ReadMult Size for Notification attribute of ncSetAttr.

The state is set whenever the specified number of frames are stored in the read queue of the object. The state is cleared when you call the read VI, and less than the specified number of frames exist in the read queue.

This state applies only to Series 1 and Series 2 interfaces.

00000040 hex Remote Wakeup

A Remote Wakeup event occurred and the Transceiver Mode for your CAN hardware has changed from Sleep to Normal. For more information on remote wakeup, refer to Transceiver Mode.

This state is set when a Remote Wakeup event occurs (end of wakeup frame). This state is not set when the application changes Transceiver Mode from Sleep to Normal (local wakeup).

This state is cleared when:

  • You open the Network Interface, such as when the application begins.

  • You stop the Network Interface.

  • You set the Transceiver Mode, such as each time you set Sleep mode.

For as long as this state is true, the Transceiver Mode is Normal. The Transceiver Mode also can be Normal when this state is false, such as when you perform a local wakeup.

00000080 hex Write Multiple

The state is set whenever there is free space in the write queue to accept at least 512 frames to write. The state is cleared when you call ncWriteNet.vi or ncWriteNetMult.vi and less than 512 frames can be accepted to write in the write queue.

This state is valid only on the Network Interface.

Timeout specifies the maximum number of milliseconds to wait for one of the states in DesiredState. If the Timeout expires before a state occurs, the error CanErrFunctionTimeout is returned in Error out (status=T, code= BFF62001 hex). If Timeout is unwired, the default value of 0 will cause the wait to return the current status immediately. Thus, it will behave like calling ncGetAttr for the Object State attribute.
Error in describes error conditions occurring before the VI executes. If an error has already occurred, the VI returns the value of the Error in cluster in Error out.
status is True if an error occurred. If status is True, the VI does not perform any operations.
code is the error code number identifying an error. A value of 0 means success. A negative value means error: VI did not execute the intended operation. A positive value means warning: VI executed intended operation, but an informational warning is returned. For a description of the code, wire the error cluster to a LabVIEW error-handling VI, such as the Simple Error Handler.
source identifies the VI where the error occurred.

Output

ObjHandle out is the object handle for the next NI-CAN VI.
DetectedState is the current state of object when desired states occur. If an error caused the wait to abort, DetectedState is zero.
Error out describes error conditions. If the Error in cluster indicated an error, the Error out cluster contains the same information. Otherwise, Error out describes the error status of this VI.
status is True if an error occurred.
code is the error code number identifying an error. A value of 0 means success. A negative value means error: VI did not execute the intended operation. A positive value means warning: VI executed intended operation, but an informational warning is returned. For a description of the code, wire the error cluster to a LabVIEW error-handling VI, such as the Simple Error Handler.
source identifies the VI where the error occurred.

Description

Use ncWaitForState.vi to wait for one or more states to occur in the object specified by ObjHandle. If an error occurs in the object, wait aborts and returns the error in Error out.

While waiting for the desired states, ncWaitForState.vi suspends execution of the current LabVIEW thread. VIs assigned to other threads can still execute. The thread of a VI can be changed in the Priority control in the Execution category of VI properties.

You cannot invoke ncWaitForState.vi twice from different VIs for the same object. For different object handles, these functions can overlap in execution.

Note  The ncWaitForState.vi function was formerly ncWait.vi.