LabWindows/CVI

Table of Contents
  • LabWindows/CVI Fundamentals
  • Creating Applications
  • Distributing Applications
  • Library Reference
  • Programmer Reference
  • Hardware Information

SetComTime

int SetComTime (int portNumber, double timeout_seconds);

Purpose

Sets timeout limit for input/output operations.

For read operations, timeout occurs when the COM port input queue is empty and no byte is read into the queue for the duration of the timeout time.

For write operations, timeout occurs when the COM port output queue is full and LabWindows/CVI cannot write to the queue for the duration of the timeout time.

SetComTime returns an error if you have not opened the port or if you pass an invalid parameter value.

Parameters

Input
Name Type Description
portNumber int A number that indicates the COM port on which to operate.

This number maps to the COM port specified by deviceName in the call to OpenCom or OpenComConfig. The portNumber 1, for example, may not necessarily map to COM1.

(Linux) The portNumber 1, for example, may not necessarily map to /dev/ttyS0.

Valid Range: 1—1,000
timeout_seconds double The timeout limit for I/O operations for the selected port.

For an RS-232 read operation, timeoutSeconds specifies the time the library allows from the start of the transfer to the arrival of the first byte. timeoutSeconds also specifies the time the library allows to elapse between the arrival of any two consecutive bytes.

An RS-232 read operation waits for at least the amount of time you specify for the next incoming byte before it returns a timeout error.

For an RS-232 write operation, timeoutSeconds specifies the time the library allows before the first byte is transferred to the output queue. timeoutSeconds also specifies the time the library allows between the transfer of any two consecutive bytes to the output queue. The transfer of bytes to the output queue can stall if the output queue is full and hardware or software handshaking is held off. If the holdoff is not resolved within the timeout period, the RS-232 write operation returns a timeout error.

If timeoutSeconds is zero, timeouts are disabled, and the read or write functions wait indefinitely for the operation to complete. The default value is 5 seconds.

Return Value

Name Type Description
returnValue int The result of this function call. This code is a negative value that specifies the type of error that occurred.

Additional Information

Library: RS-232 Library

Include file: rs232.h

LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later

Example

Refer to rs232\serial.cws for an example of using the SetComTime function.

Log in to get a better experience