Remote Command Processing Code
C–56 WFM 601A, WFM 601E & WFM 601M User Manual
/*
* Module WARNINGS (these warnings indicate bad communications or
* invalid requests to the instrument)
*/
#define W_INVALID_RESP -1 /* Invalid response from instrument */
#define W_UNEXPEC_RESP -2 /* Unexpected response from instrument */
/* Local communications port */
static int comPort;
/*
* init601Port - Initialize the port to communicate with the WFM601x
*
* This procedure connects the program to a COM port, attempts to open it,
* and initialize communications with the instrument. It returns either
* A_OK (0), or an error code value indicating the problem.
*/
int
init601Port
(
int desiredComPort /* The desired COM portĊfrom 1 to 4 */
)
{
static unsigned char ioBuf[IO_BUFSIZ]; /*Buf used by IO lib */
int lStat, mStat; /* Required status */
register int tryCounter; /* Count tries */
register int errCode; /* Keep error values */
/* Check arguments for sanity */
if ( desiredComPort<1||desiredComPort>4)
return INV_PORT;
/* Set the desired communications port */
comPort = desiredComPort;
/* Repeatedly attempt to initialize and open serial port */
for (tryCounter = 0; tryCounter < NUMBER_OF_RETIRES; tryCounter++)
{
/*
* Initialize port protocol:
* port #, 9600 Baud, no parity, no stop bits, 8 bit data
*/
errCode = init_a1(comPort, 7, 0, 0, 3, &lStat, &mStat);
/*
* If port initialized without error, open port and return
*/
if (errCode == OKAY)
{
errCode = open_a1(comPort,
sizeof(ioBuf) / 2, sizeof(ioBuf) / 2, 0, 0, ioBuf);