Scanlist command – Rockwell Automation 6008-SV2R VMEbus remote I/O Scanner User Manual

Page 141

Advertising
background image

Chapter

Programming the Scanner

8

8Ć7

SCANLIST command

/*
**
** SCANLIST() –– configure a 6008–SV2 channel scan list
**
**

This function executes a SCANLIST command, using the scanlist provided by the

**

caller in the scanlist_data parameter.

**
**

parameters:

pointer to channel structure

**

pointer to scanlist_data structure

**

return values:

–1

= unable to lock general data area semaphore

**

–2

= did not get cmd–complete interrupt

**

ELSE

channel confirmation status word

**
*/

int
scanlist (channel far *chan, scanlist_data far *scancfg)
{

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, ”scanlist: lock aquire FAILED\n”);
return –1;

}

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

/* confirm status word */

csa–>cmd

= CMD_SCANLIST;

/* command word */

csa–>datalen = scancfg–>scanlist_len;

/* length of data word */

/* copy the scan list to the general data area */
blockcpy(chan–>GeneralDataArea, scancfg–>scanlist,

(size_t) scancfg–>scanlist_len);

/* 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, ”scanlist: 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: