Programming Examples
Appendix B
B-12
/***************************************************************************
** **
** MAIN LOOP **
** **
** The main loop writes data into the output image table for each of **
** the adapters that are in the scan list. It also looks for a change **
** in data for one adapter. If a certain value appears, a BT command **
** is initiated. It waits for completion of the BT before continuing **
** which is useful for these examples, but not practical in a real **
** application. **
** **
***************************************************************************/
while (ktx_alive) {
/**** Write the output image table for 0x04 (full rack) ****/
for (i=0, out.count = FULL_RACK_SIZE; i< out.count; i++) out.data[i]++;
status = put_output_data (dp, 0x04, &out);
/**** Write the output image table for 0x0E (half rack) ****/
for (i=0, out.count = HALF_RACK_SIZE; i< out.count; i++) out.data[i]++;
status = put_output_data (dp, 0x0E, &out);
/**** Write the output image table for 0x13 (quarter rack) ****/
for (i=0, out.count = QUARTER_RACK_SIZE; i< out.count; i++) out.data[i]++;
status = put_output_data (dp, 0x13, &out);
/**** Read the input image table ****/
status = get_IO_data(dp, 0x04, &in, INPUT_TABLE);
/**** Initiate a BT Read and a BT Write ****/
/**** BT Read 32 words from slot 15, ****/
/**** then BT write same data to slot 13 ***/
/**** if the BT read was successful ****/
/**** Assume that in.data[4] can change ****/
if (in.data[4] & 0x0100) {
bt_buffer.count = 32;
status = bt_read (dp, 15, 0x04, &bt_buffer,
++trans_count, BT_READ_TMO);
if (status == SUCCESS)
status = bt_write (dp, 13, 0x04, &bt_buffer,
++trans_count, BT_WRITE_TMO);
}
}
/**** Reset the old interrupt handler before exiting */
setvect(CLOCK_INTR, oldhandler);
/**** Turn off watchdog ****/
dp–>host_dead_counter = 0;
dp–>alive_flag = HOST_ALIVE;
/**** Deassert the KTX ****/
dp–>deassert_reg = TRUE;
exit (FAIL);
}