![National Instruments AT-DIO-32F User Manual Download Page 112](http://html1.mh-extra.com/html/national-instruments/at-dio-32f/at-dio-32f_user-manual_3441269112.webp)
Appendix C
Application Notes
© National Instruments Corporation
C-3
AT-DIO-32F User Manual
/* set up AT-DIO-32F to communicate with printer */
Setup_DIO(); /* setup the AT-DIO-32F */
/* get the chars to print and send out */
printf("\nEnter the name of the file to print: \n");
scanf("%s",filename);
/* gets(filename);*/
fp = fopen(filename,"r");
if ( Valid_file()) /* test if a valid file opened */
Read_n_Write(); /* read the file and send to printer */
fclose(fp);
} /* main */
/***************** functions *************************************/
/* read file and print */
Read_n_Write()
{
char ch;
while ((ch=fgetc(fp)) != EOF) /* print chars until EOF is reached */
{
Print_char(ch);
}
Print_char(0x0D); /* send linefeed to complete printing */
}
/* check whether given filename is valid */
Valid_file()
{
if (fp == NULL)
{
printf("\nCan't open the file %s.",filename);
return(0);
/* no file access */
}
else
return(1);
/* file exists, go ahead */
}
/* setup the AT-DIO-32F board */
Setup_DIO()
{
outpw(cfg1, 0x0000);
/* initialize the board */
outpw(cfg2, 0x0000);
outpw(cfg3, 0x0000);
outpw(cfg4, 0x0001);
outpw(cfg2, 0x001);
/* OUT2 = *INIT high */
outpw(cfg1, 0x2B44);
/* reset porta handshaking */
outpw(cfg1, 0x2A44); /* porta level, invert ACK1 and REQ1, delay=500ns */
outpw(cfg3, 0x0400);
/* porta write */
}
/* check printer is ready */
Printer_Rdy()
{
int err = 0;
Summary of Contents for AT-DIO-32F
Page 19: ......
Page 101: ......
Page 102: ......
Page 123: ......
Page 124: ......
Page 125: ......
Page 126: ......
Page 127: ......
Page 128: ......
Page 129: ......
Page 130: ......
Page 131: ......
Page 132: ......
Page 133: ......
Page 134: ......
Page 135: ......
Page 136: ......
Page 137: ......
Page 138: ......
Page 139: ......
Page 140: ......
Page 141: ......
Page 142: ......
Page 143: ......