#include #include #include /* contains the prototype for usleep */ int main(int argc, char **argv) { int indata; int fd; int p; // portdata to send to parallel port int temp = 0x01; int i; unsigned int sph; // short pulse height unsigned long int sprd; // short pulse rise delay unsigned long int spfd; // short pulse fall delay unsigned int lph; // long pulse height unsigned long int lprd; // long pulse rise delay unsigned long int lpfd; // long pulse fall delay if (argc < 7) { fprintf(stderr,"%s sp_height sp_rise_delay sp_fall_delay lp_height lp_rise_delay lp_fall_delay\n",argv[0]); exit(0); } sph = (unsigned int) strtol(argv[1],NULL,10); sprd = (unsigned long) strtol(argv[2],NULL,10); spfd = (unsigned long) strtol(argv[3],NULL,10); lph = (unsigned int) strtol(argv[4],NULL,10); lprd = (unsigned long) strtol(argv[5],NULL,10); lpfd = (unsigned long) strtol(argv[6],NULL,10); printf("sph = %d\n",sph); printf("sprd = %lu\n",sprd); printf("spfd = %lu\n",spfd); printf("lph = %d\n",lph); printf("lprd = %lu\n",lprd); printf("lpfd = %lu\n",lpfd); /* attempt to open i-bus device */ //if((fd = open("/dev/ibus0", O_RDWR)) < 0) { if((fd = open("/dev/ibus1", O_RDWR)) < 0) { fprintf(stderr, "Cannot open i-bus device, aborting...\n"); exit(1); } p = 0x00; temp = 0x01; for (i=0;i> 1); usleep(spfd); // delay going down short pulse } // this is long pulse p = 0x00; temp = 0x01; for (i=0;i> 1); usleep(lpfd); // delay going down long pulse } /* attempt to close i-bus device */ if(close(fd) < 0) { fprintf(stderr, "Cannot close i-bus device, aborting...\n"); exit(1); } return(0); /* just to be nice ;) */ }