/*********************************************************************/

/*

BOOL OpenCommunications(int ComPort, int ComBaud)

*/

/*

Description

: This function is to Open the communication port

*/

/*

and set the port settings

 

*/

/*

Inputs :

int - ComPort

entered as a command line argument

*/

/*

 

int - ComBaud

The Baud rate for Communication

*/

/*

Returns:

SUCCESS - If the Communication link was established*/

/*

 

FAIL - IF there was an error opening the COM Port

*/

/*********************************************************************/ BOOL OpenCommunications(int ComPort, int ComBaud)

{

 

 

 

DCB

CommSettings;

// Structure with COM Port settings

LPCTSTR ComPortNumber;

// Pointer to the

COM port number

BOOL PortReady;

// Return val after setting the COM Port

COMMTIMEOUTS timeout;

// Structure with

Time out values

switch (ComPort)

{

case ‘1’:

ComPortNumber = “COM1"; break;

case ‘2’:

ComPortNumber = “COM2"; break;

case ‘3’:

ComPortNumber = “COM3"; break;

case ‘4’:

ComPortNumber = “COM4"; break;

default:

CloseHandle(ComHandle);

fclose(fp);

exit(0);

break;

}

/* Creating a File to Open a COM Port*/ ComHandle = CreateFile( ComPortNumber,

GENERIC_READ GENERIC_WRITE, 0, // exclusive access NULL, // no security

Site Master PM

113

Page 119
Image 119
Anritsu S332D, S331D manual Site Master PM 113, Baud rate for Communication Returns