void testPP() { IOBase *io; io=new IOParport; io->dev_open(PPDEV); unsigned char tdi[]={0,0,0,0,0,0,0,0}; unsigned char tdo[100]; io->setTapState(IOBase::SHIFT_DR); io->shiftTDITDO(tdi,tdo,64); for(int i=0; i<8; i++)printf("TDO %02x\n",tdo[i]); printf("\n"); getSwitches(io); getID(io); delete io; }
int main(int argc, char **args) { bool verbose = false; char *device = NULL; int ch, ll_driver = DRIVER_PARPORT; IOBase *io; IOParport io_pp; IOFtdi io_ftdi; // Produce release info from CVS tags char release[]={"$Name: Release-0-5 $"}; char *loc0=strchr(release,'-'); if(loc0>0){ loc0++; char *loc=loc0; do{ loc=strchr(loc,'-'); if(loc)*loc='.'; }while(loc); release[strlen(release)-1]='\0'; // Strip off $ } printf("Release %s\n",loc0); // Start from parsing command line arguments while ((ch = getopt(argc, args, "c:d:v")) != -1) switch ((char)ch) { case 'c': if (strcmp(optarg, "pp") == 0) ll_driver = DRIVER_PARPORT; else if (strcmp(optarg, "ftdi") == 0) ll_driver = DRIVER_FTDI; else usage(); break; case 'd': device = strdup(optarg); break; case 'v': verbose = true; break; default: usage(); } if ((device == NULL) && (ll_driver == DRIVER_PARPORT)) if(getenv("XCPORT")) device = strdup(getenv("XCPORT")); else device = strdup(PPDEV); switch (ll_driver) { case DRIVER_PARPORT: io = &io_pp; break; case DRIVER_FTDI: io = &io_ftdi; break; default: usage(); } io->setVerbose(verbose); printf("argc: %d\n", argc); // Get rid of options argc -= optind; args += optind; printf("argc: %d\n", argc); if(argc<1) usage(); io->dev_open(device); if(io->checkError()){ if (ll_driver == DRIVER_FTDI) fprintf(stderr, "Could not access USB device (%s).\n", (device == NULL) ? "*" : device); else { fprintf(stderr,"Could not access parallel device '%s'.\n", device); fprintf(stderr,"You may need to set permissions of '%s' \n", device); fprintf(stderr, "by issuing the following command as root:\n\n# chmod 666 %s\n\n", device); } return 1; } free(device); int chainpos=0; if(argc>1)chainpos=atoi(args[1]); if(verbose) printf("JTAG chainpos: %d\n", chainpos); int length; BitFile file; if((length = file.load(args[0]))) { if (verbose) { printf("Created from NCD file: %s\n",file.getNCDFilename()); printf("Target device: %s\n",file.getPartName()); printf("Created: %s %s\n",file.getDate(),file.getTime()); printf("Bitstream length: %d bits\n",length); } process(*io, file, chainpos, verbose); } else return 1; return 0; }