/* * iktest0.c * * simple(!) sample program that opens ihpc0, * calls ioctl to set the dma timeout to 10 seconds, * sets to print mode if VPI interface selected * calls write to output a repeating message, * calls write again to do a form feed, and then dumps the registers * * Tahoma Technology * (formerly Ikon Corporation) * 107 2nd Avenue North * Seattle, WA, USA 98109 * * 206.728.6465 * http://www.tahomatech.com * tahoma@tahomatech.com * * ????? initial coding * * 6 May, 2002 updated company info and added VPI print mode selection * and banner * 17 May, 2002 corrected typo in printf string * * 17 June, 2002 corrected version string * * 5 October, 2005 added includes to keep newer versions of Linux happy, * converted ioctl arg to __u32 to preserve size in 64 bit mode */ #include #include #include #include #include #include "./ihcp_io.h" /* also picks up types.h for __u32 */ #define DEVICE "/dev/ihcp0" static char version_string[] = { "iktest0, 31 October, 2005"}; static char tahoma_banner[] ={ "Tahoma Technology (formerly Ikon Corporation), Seattle, WA, USA"}; main() { int i, err, filedes; __u32 argarray[19]; printf("\n%s\n",version_string); printf("%s\n", tahoma_banner); filedes = open(DEVICE, O_RDWR); if(filedes == -1) { perror("error on open"); exit(0); } printf("filedescriptor = 0x%x\n", filedes); argarray[0] = 10; err = ioctl(filedes, IHCPIO_SET_DMATIME, argarray); if(err == -1) { perror("error on SET_DMATIME ioctl"); exit(0); } err = ioctl(filedes, IHCPIO_GET_BOARD, argarray); if(err == -1) { perror("error on GET_BOARD ioctl"); exit(0); } if(argarray[0] == IHCPIO_CENT) printf("board strapped for CENTRONICS\n"); else { printf("board strapped for VPI - setting PRINT mode\n"); argarray[0] = IHCPIO_V_NPRINT; err = ioctl(filedes, IHCPIO_SET_VMODE, argarray); if(err == -1) { perror("error on SET_VMODE ioctl"); exit(0); } } for (i = 0; i < 10; i++) { err = write(filedes, "hello world!\r\n", 14); if (err == -1) { perror("error on write call #1"); exit(0); } } err = write(filedes, "\r\f", 2); if (err == -1) { perror("error on write call #2"); exit(0); } err = ioctl(filedes, IHCPIO_GET_REGS, argarray); if (err == -1) { perror("error on GET_REGS ioctl"); exit(0); } for (i = 0; i < 19; i++) printf("arg[%d] = 0x%x\n", i, argarray[i]); printf("DONE\n"); }