ProSoft Technology MVI69-ADM User Manual

Page 253

Advertising
background image

MVI-ADM ♦ 'C' Programmable

Serial Port Library Functions

'C' Programmable Application Development Module

Developer's Guide

ProSoft Technology, Inc.

Page 253 of 342

February 20, 2013

MVIsp_Puts

Syntax

int MVIsp_Puts(int comport, BYTE *str, BYTE term, int *len, DWORD timeout);

Parameters

comport

port to which data is to be sent

str

string of characters to be sent

term

termination character of string

len

pointer to BYTE to receive number of characters sent

timeout

amount of time to wait to send character

Description
This function transmits a string of characters across a serial port. comport must
be previously opened with MVIsp_Open.

str is a pointer to an array of characters (or is a string) to be sent.

MVIsp_Puts sends each char in the array str to the serial port until it encounters
the termination character term. Therefore, the character array must end with the
termination character. The termination character is not sent to the serial port.

All data sent to a port is queued before transmission across the serial port.
Therefore, some delay may occur between the time this function returns and the
actual time that the characters are transmitted across the serial line. This function
attempts to insert the characters into the transmission queue, and return values
correspond accordingly.

timeout specifies the amount of time in milliseconds to wait. If timeout is
TIMEOUT_ASAP, the function will return immediately if any of the characters
cannot be queued immediately. If timeout is TIMEOUT_FOREVER, the function
will not return until all the characters are queued successfully.

If all the characters can be queued immediately, MVIsp_Puts returns
MVI_SUCCESS. If the characters cannot be queued immediately, MVIsp_Puts
tries to queue the characters until the timeout elapses. If the timeout elapses
before the characters can be queued, MVI_ERR_TIMEOUT is returned.

If len is not NULL, MVIsp_Puts writes to the int pointed to by len the number of
characters queued successfully. len is written for successfully sent characters as
well as timeouts.

Note: If handshaking is enabled and the receiving serial device has paused transmission, timeouts
may occur after the queue becomes full.

Return Value

MVI_SUCCESS

the characters were sent successfully

MVI_ERR_NOACCESS

comport has not been opened

MVI_ERR_BADPARAM

invalid parameter

MVI_ERR_TIMEOUT

timeout elapsed before characters sent

Advertising