beautypg.com

Bt_done – Rockwell Automation 6008-SI IBM PC I/O SCNNR 6008-SI User Manual

Page 100

background image

Chapter 8

Block Transfer

8-10

bt_done

Your program could monitor the status of a BT directly by an if test as
shown above, but it may be clearer to use the bt_done macro, like this:

if ( bt_done(&btrpkt) ) . . .

bt_done is a macro that compiles to the if test given earlier. The only
difference is that bt_done may make your program read a little more
clearly.

Calling sequence:

status = bt_done(

&packet

);

Arguments:

packet:

a pointer to a packet that has previously been the argument of a

bt_que, bt_read, or bt_write call.

Returned values:

false (0) if the BT is still pending, true (nonzero) if it has finished

successfully or unsuccessfully.

Once bt_done returns a value of true, you can interrogate the status as
we did above.

bt_done is not limited to the (rare) case where your program doesn’t
want to do anything else until the BT has finished, but the logic of that
case is particularly clear when we use bt_done:

static QBT btr;
#define CHANNEL_IN (16*2 + 3) /* slot 3, rack 2 */

. . .

btr.qbt_len = 15;
if ( bt_que(C_BT_READ, CHANNEL_IN, &btr) )

printf(“can’t queue the read BT\n”);

else

while ( !bt_done(&btr) )

; /* empty wait loop */

if ( pkt.qbt_stat == SC_OK ) {

/* successful completion */
}
else {

/* BT failed; pkt.qbt_stat contains reason */

}