Serial port api communications – ProSoft Technology MVI69-ADM User Manual

Page 251

Advertising
background image

MVI-ADM ♦ 'C' Programmable

Serial Port Library Functions

'C' Programmable Application Development Module

Developer's Guide

ProSoft Technology, Inc.

Page 251 of 342

February 20, 2013

9.4

Serial Port API Communications

MVIsp_Putch

Syntax

int MVIsp_Putch(int comport, BYTE ch, DWORD timeout);

Parameters

comport

port to which data is to be sent

ch

character to be sent

timeout

amount of time to wait to send character

Description
This function transmits a single character across a serial port. comport must be
previously opened with MVIsp_Open.

ch is the byte to be sent.

All data sent to a port is queued before transmission across the serial port.
Therefore, some delay may occur between the time after this function returns
and the actual time that the character is transmitted across the serial line. This
function attempts to insert the character 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 the character cannot be
queued immediately. If timeout is TIMEOUT_FOREVER, the function will not
return until the character is queued successfully.

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

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 char was sent successfully

MVI_ERR_NOACCESS

comport has not been opened

MVI_ERR_BADPARAM

invalid parameter

MVI_ERR_TIMEOUT

timeout elapsed before character sent

Example

if (MVIsp_Putch(COM1, ';', 1000L) != MVI_SUCCESS)
printf("Semicolon could not be sent in 1 second\n");

See Also
MVIsp_GetCh (page 252)

MVIsp_Puts (page 253)

Advertising