Serial port api configuration functions – ProSoft Technology MVI69-ADM User Manual

Page 240

Advertising
background image

Serial Port Library Functions

MVI-ADM ♦ 'C' Programmable

Developer's Guide

'C' Programmable Application Development Module

Page 240 of 342

ProSoft Technology, Inc.

February 20, 2013

9.2

Serial Port API Configuration Functions

MVIsp_Config

Syntax

int MVIsp_Config(int comport, BYTE baudrate, BYTE parity, BYTE wordlen, BYTE
stopbits);

Parameters

comport

Communications port to configure

baudrate

Baud rate for this port

parity

Parity setting for this port

wordlen

Number of bits for each character

stopbits

Number of stop bits for each character

baudrate

Pointer to DWORD to receive baudrate

Description
MVIsp_Config allows the configuration of a serial port to be changed after it has
been opened.

comport specifies which port is to be configured.

baudrate is the desired baud rate.

Valid values for parity are PARITY_NONE, PARITY_ODD, PARITY_EVEN,
PARITY_MARK, and PARITY_SPACE.

wordlen sets the word length in number of bits per character. Valid values for
word length are WORDLEN5, WORDLEN6, WORDLEN7, and WORDLEN8.

The number of stop bits is set by stopbits. Valid values for stop bits are
STOPBITS1 and STOPBITS2.

Note: If the console is enabled or the Setup jumper is installed, the baud rate for COM1 is set as

configured in BIOS Setup and cannot be changed by MVIsp_Open. MVIsp_Config will return
MVI_SUCCESS, but the baud rate will not be affected.

Return Value

MVI_SUCCESS

No errors were encountered

MVI_ERR_NOACCESS

comport has not been opened

MVI_ERR_BADPARAM

invalid pointer

Example

if (MVIsp_Config(COM1,BAUD_9600,PARITY_NONE,WORDLEN8,STOPBITS1) != MVI_SUCCESS)
{
printf("Config failed!\n");
} else {
printf("Config succeeded\n");
}

Advertising