Transmit 10 requests and wait for 10 responses, Release the send box */ fsendboxavailable = fal, Check if the receive box is available */ if (fr – Rockwell Automation D17846.2.4 CONTROLNET KT EMULA User Manual

Page 34: Release the receive box */ frecvboxavailable, Shutdown the interrupt system, Mask the interrupt */ outport(0x20+1, inport(0x, Turn of the ktc interrupt trigger */ outportb, Restore the vector */ setvect(0xd, oldhander), Shutdown kt emulation */ cprintf("taking kt emu

Advertising
background image

1784-6.2.4 - September 1997

A-4

Example Code for Polled and Interrupt Messaging

/* Transmit 10 requests and wait for 10 responses */
for (i=0; i < 10;)
{

/* check if the send box is available */
if (fSendBoxAvailable == TRUE)
}

/* Place an id host and stat message into the dualport */
pDP->comm.send.len = 0x11;
pDP->comm.send.dst = 1;
pDP->comm.send.lsap = 0;
memcpy(&pDP->comm.send.data[0], abIDHost, size of(abIDHost));

/* release the send box */
fSendBoxAvailable = FALSE;
pDP->comm.send.shake2 = 0;
pDP->comm.send.shake1 = 0;

}

/* check if the receive box is available */
if (fRecvBoxAvailable == TRUE)
{

/* Print the response out */
ptr=pDP->comm.rev.data;
cprint("Response %2d: -,i):
for (j=0; j <pDP->comm.rev.len; ++j)
{
cprintf("%02X", *(ptr+j));
}
cprintf("\n\r");

/* release the receive box */
fRecvBoxAvailable = FALSE;
pDP->comm.rev.shake2= 0;
pDP->comm.rcv.shake1= 0;
i++;

}

}

/* SHUTDOWN the interrupt system */

/* mask the interrupt */
outport(0x20+1, inport(0X20+1) | 0X20);

/* turn of the KTC interrupt trigger */
outportb( HIRQCTRL1, 0 );
outportb( HIRQCTRL2,0 );

/* restore the vector */
setvect(0xD, oldhander);
cprintf("\r\n---->%5d",iNumInts);

/* shutdown KT emulation */
cprintf("Taking KT Emulation mode offline (shutdown emulation)\r\n");
pDP->comm.online=0xff;
pDP->comm.shutdown_trig=0x01;
cprintf("Waiting for KT stopped flag to go to 0xFF.....\r");
while (!kbhit() & &(pDP->comm.shutdown_stat ! = -1))
{
}
cprintf("KT has been shutdown \r");
*pReset = 1;
pDp->comm.heartbeat = 4;
PDp->comm.shutdown_trig = 0

Advertising