8ć10, Set mode command – Rockwell Automation 6008-SV2R VMEbus remote I/O Scanner User Manual

Page 144

Advertising
background image

Chapter

Programming the Scanner

8

8Ć10

SET MODE command

/*
**
** SETMODE() –– configure 6008–SV2 channel operating mode
**
**

This function executes a SET MODE command, using the mode passed by the caller in

**

the mode parameter.

**
**

parameters:

pointer to channel structure

**

mode parameter (1 = PROGRAM, 2 = TEST, 4 = RUN)

**

return values:

–1

= unable to lock general data area semaphore

**

–2

= did not get cmd–complete interrupt

**

ELSE

channel confirmation status word

**
*/

int
setmode (channel far *chan, int mode)
{

csa_data far

*csa;

unsigned short

res;

/* map channel & establish pointers */
map_channel(chan);
csa = (csa_data far *) chan–>ControlStatusArea;

/* get the semaphore */
if (lock_gda(chan) != 0) {

unmap_channel(chan);
fprintf(stdout, ”set mode: lock aquire FAILED\n”);
return –1;

}

/* set up the control/status area */
csa–>cnfstat = 0x000F;

/* confirmation status word */

csa–>cmd

= CMD_SETMODE;

/* command word */

csa–>datalen = 0x0001;

/* length of data word */

/* put mode parameter in general data area */
*chan–>GeneralDataArea = (unsigned char) mode;

/* send the command interrupt */
assert_cmd(chan);

/* poll for command result */
if (wait_for_cmdcmpl(chan) == FALSE) {

/* clear the semaphore */
unlock_gda(chan);
unmap_channel(chan);
fprintf(stdout, ”setmode: wait failure, lock cleared\n”);
return –2;

}

/* clear the semaphore & unmap the channel */
res = csa–>cnfstat;
unlock_gda(chan);
unmap_channel(chan);
return (int) res;

}

Advertising
This manual is related to the following products: