#include #include #include "idrio.h" char datarray[16000] ; int ii, i, filedes ; extern errno ; char devname[31]; static union { char ch[256]; u_long ulg[64] ; } arg ; /* This is a very simple example of a DR11 interprocessor link using the IKON model 10103 Sbus dr11 emulator. It uses the standard interprocessor link protocol, although without some of the bells and whistles that a robust link would probably incporate. The strange block size of 0x2002 bytes matches the block size used at IKON for factory link testing of various DR11 emulators */ main() { /* open the device */ strcpy(devname,"/dev/idr0\0") ; filedes = open(devname,O_RDWR) ; printf("filedes = 0x%x\n",filedes) ; /* pre-configure the read and write logic to send an attention (clear to send) to the other end when DVMA reads are enabled, and to force a local cycle when writes are started */ arg.ulg[0] = IDR_ACF2 ; ii = ioctl(filedes,IDRIO_READ_PULSE,arg.ulg) ; arg.ulg[0] = IDR_CYCL ; ii = ioctl(filedes,IDRIO_WRITE_PULSE,arg.ulg) ; /* loop forever */ while(1) { /* we must reset the invisible UNIX counter to 0 every so often */ lseek(filedes,(off_t)0,0) ; for(i=0;i<1000;i++) { /* wait for the request to send from the other end */ ii = ioctl(filedes,IDRIO_ATTN_WAIT,arg.ulg) ; /* issue the read (and clear to send) */ ii = read(filedes,datarray,0x2002) ; if(ii == -1) printf("error on read, errno = 0x%x\n",errno) ; arg.ulg[0] = IDR_ACF2 ; ii = ioctl(filedes,IDRIO_IMM_PULSE,arg.ulg) ; /* wait for clear to send */ ii = ioctl(filedes,IDRIO_ATTN_WAIT,arg.ulg) ; /* do the write */ ii = write(filedes,datarray,0x2002) ; if(ii == -1) printf(" error on write, errno = 0x%x\n",errno) ; } } /* below is a source only example of how to read the board's registers */ /* ii = ioctl(filedes,IDRIO_GET_REGS,arg.ulg) ; printf("ii after ioctl = 0x%x\n",ii) ; printf("10103 regs = \n") ; printf("CSR = 0x%x\n",arg.ulg[0]) ; printf("DADD = 0x%x\n",arg.ulg[1]) ; printf("DRNG = 0x%x\n",arg.ulg[2]) ; printf("mode = 0x%x\n",arg.ulg[3]) ; printf("latch = 0x%x\n",arg.ulg[4]) ; printf("stat = 0x%x\n",arg.ulg[5]) ; printf("dathi = 0x%x\n",arg.ulg[6]) ; printf("datlo = 0x%x\n",arg.ulg[7]) ; printf("rhi = 0x%x\n",arg.ulg[8]) ; printf("rmid = 0x%x\n",arg.ulg[9]) ; printf("rlow = 0x%x\n",arg.ulg[10]) ; */ }