int main( void ) { I16 card = -1, card_number = 0; U32 input, out_value = 0; if((card = Register_Card(PCI_7248, card_number))<0) { printf ("Can't open device file: PCI7248\n"); exit(-1); } printf("open device file successfully!!\n"); DIO_PortConfig(card,Channel_P1A, INPUT_PORT); DIO_PortConfig(card,Channel_P2A, OUTPUT_PORT); DIO_PortConfig(card,Channel_P1B, INPUT_PORT); DIO_PortConfig(card,Channel_P2B, OUTPUT_PORT); DIO_PortConfig(card,Channel_P1C, INPUT_PORT); DIO_PortConfig(card,Channel_P2C, OUTPUT_PORT); clrscr(); printf("PCI-7248 DIO Sample :\n\n"); printf("-------------------------------------------------\n"); printf(" P1A, p1B, P1C are configured as input port.\n"); printf(" P2A, p2B, P2C are configured as output port.\n"); printf("-------------------------------------------------\n"); printf(" Press any key to continue...\n"); getch(); do { clrscr(); printf ("PCI-7248 DIO Sample :\n\n"); printf ("-------------------------------------------------\n"); printf (" P1A, p1B, P1C are configured as input port.\n"); printf (" P2A, p2B, P2C are configured as output port.\n\n"); DO_WritePort(card, Channel_P2A, out_value); printf(" P2A output = 0x%x\n", (U16)out_value); DI_ReadPort(card, Channel_P1A, &input); printf(" P1A input = 0x%x\n", (U16)input); DO_WritePort(card, Channel_P2B, out_value); printf(" P2B output = 0x%x\n", (U16)out_value); DI_ReadPort(card, Channel_P1B, &input); printf(" P1B input = 0x%x\n", (U16)input); DO_WritePort(card, Channel_P2C, out_value); printf(" P2C output = 0x%x\n", (U16)out_value); DI_ReadPort(card, Channel_P1C, &input); printf(" P1C input = 0x%x\n", (U16)input); printf ("-------------------------------------------------\n"); printf (" Press ENTER to stop...\n"); //usleep(100000); out_value = (out_value+1)%256; } while(!kbhit()); if(card>=0) { Release_Card(card); } return 0; }
int main(void) { int err; char temp_char; setbuf( stdout, NULL ); printf("PCI-7396 Interrupt Sample (INT1)\n" ); printf("This program shows the number of occurrence\n"); printf("of COS INT1 interupt. COS INT1 interrupt is\n"); printf("generated by external signal from DI Port 1.\n"); printf("If you connect CN1 to CN2, press any key can generate an interrupt.\n"); printf("Or press ESC for exit\n\n" ); int_count=0; if ((card=Register_Card(PCI_7396, card_number)) < 0) { printf("Register_Card Error = %d\n", card); exit(0); } if( DIO_PortConfig(card,Channel_P1, INPUT_PORT) != NoError ) goto exit_after_error; if( DIO_PortConfig(card,Channel_P2, OUTPUT_PORT) != NoError ) goto exit_after_error; //DIO_SetCOSInterrupt(card, Channel_P1, 1, 1, 1); err = DIO_SetDualInterrupt(card, INT1_FP1C0, INT2_DISABLE, sig1_handler, NULL); if( err != NoError ){ printf(" error from DIO_SetDualInterrupt : %d \n" , err ); goto exit_after_error; } while(1){ temp_char = getch(); if( temp_char == 0x1b ) break; DO_WritePort(card,Channel_P2C, 0x1); usleep(1000); DO_WritePort(card,Channel_P2C, 0x0); usleep(1000); } DIO_SetDualInterrupt(card, INT1_DISABLE, INT2_DISABLE, NULL, NULL); exit_after_error: if (card >= 0) Release_Card(card); exit(0); }
int main( void ) { I16 card=-1, card_number = 0; U32 input = 0; if ((card=Register_Card(PCI_7433, card_number)) < 0) { printf ("Can't open device file: PCI7433\n"); exit(-1); } printf ("open device file successfully!!\n"); do { clrscr(); printf ("PCI-7433R DIO Sample :\n\n"); printf ("The Data from DI are shown in the following table:\n"); printf ("--------------------------------------------------\n"); DI_ReadPort(card, PORT_DI_LOW, &input); printf(" DI low port input = 0x%lx\n", input); DI_ReadPort(card, PORT_DI_HIGH, &input); printf(" DI high port input = 0x%lx\n", input); DO_WritePort(card, P7433R_DO_LED, input); printf(" LED output = 0x%lx\n", (input)); printf ("--------------------------------------------------\n"); printf (" Press Enter to stop...\n"); //usleep(100000); }while( !kbhit() ); if(card>=0) { Release_Card(card); } return 0; }
int main(void) { I16 card = -1, card_number = 0; U32 out_value = 1; if((card = Register_Card(PCI_7234, card_number))<0){ printf("Can't open device file: PCI7234\n"); exit(-1); } printf("open device file successfully!!\n"); do{ clrscr(); printf("PCI-7234 DO Sample :\n"); printf("\nThe Data to DO are shown in the following table:\n\n"); printf("-------------------------------------------------\n"); DO_WritePort(card, 0, out_value); printf(" Do port output = 0x%lx\n", (out_value)); printf("-------------------------------------------------\n"); printf(" Press Enter to stop...\n"); //usleep(100000); out_value = (out_value*2)%((1<<31)+1); if(!out_value) out_value = 1; }while(!kbhit()); if(card>=0){ Release_Card(card); } return 0; }
int main( void ) { I16 card = -1, card_number = 0; U32 input, out_value = 0; if((card = Register_Card(PCI_6208V, card_number))<0){ printf("Can't open device file: PCI6208V\n"); exit(-1); } do{ clrscr(); printf("PCI-6208V DIO Sample :\n"); printf("\nThe Data to/from DO/DI are shown in the following table:\n"); printf("--------------------------------------------------------\n"); DO_WritePort(card, 0, out_value); printf(" DO port output = 0x%x\n", (U16)(out_value&0x0f)); usleep(100); DI_ReadPort(card, 0, &input); printf(" DI port input = 0x%x\n", (U16)(input&0x0f)); printf("--------------------------------------------------------\n"); //if(stop_flag) break; printf(" Press Enter to stop...\n"); //usleep(100000); out_value = (out_value+1)%16; }while(!kbhit()); if(card>=0){ Release_Card(card); } return 0; }
int main( void ) { I16 card; U32 input=0, output_value=0; if ((card=Register_Card (PCI_9111DG, 0)) <0 ) { printf("Register_Card error=%d", card); exit(1); } printf("\n Press Enter for Exit \n"); do{ clrscr(); printf("*****************************************************************\n" ); printf(" PCI9111 IO Polling \n"); printf("*****************************************************************\n\n"); printf(" \n\n\n\n"); DO_WritePort(card,0, output_value); printf(" Value write to OUTPUT PORT : %02x \n\n", (U16)output_value); DI_ReadPort(card,0,&input); printf(" Value read from INPUT PORT : %02x \n\n\n\n\n\n\n", (U16)input ); printf(" press Enter to stop \n\n\n"); usleep( 10000 ); if( output_value == 0xff ) output_value = 0; else output_value ++; }while( !kbhit() ); Release_Card( card ); return 0; }
int main(void) { int err; char temp_char; int card_number = 0; setbuf(stdout, NULL); printf(" Please input the Card Index: "); scanf(" %d", &card_number); system("clear"); printf("PCI-7258 Interrupt Sample (INT1)\n\n"); printf("This program shows the number of occurrence of INT1 interupt.\n"); printf("INT1 interrupt is generated by external signal from DI bit-0/bit-1.\n"); printf("Press ESC for exit\n\n"); int_count = 0; if((card = Register_Card(PCI_7258, (I16)card_number))<0){ printf ("Can't open device file: PCI7258\n"); exit(-1); } DO_WritePort(card,0, out_Val); err = DIO_SetDualInterrupt(card, INT1_EXT_SIGNAL, INT2_DISABLE, sig1_handler, NULL ); if(err!=NoError){ printf(" error from DIO_SetDualInterrupt : %d \n" , err ); goto exit_after_error; } while(1){ temp_char = getch(); if(temp_char==0x1b) break; DO_WritePort(card, 0, 0x0); sleep(0); DO_WritePort(card, 0, 0x1); } DIO_SetDualInterrupt(card, INT1_DISABLE, INT2_DISABLE, NULL, NULL); DO_WritePort(card, 0, 0x0); exit_after_error: if(card>=0) Release_Card(card); exit(0); }
int main(void) { int err; char temp_char; setbuf( stdout, NULL ); printf("PCI-7432 Dual Interrupt Sample\n" ); printf("This program shows the number of occurrence of interrupt\n" ); printf("for Dual interrupt lines.\n" ); printf("INT1 interrupt is generated by external signal from DI bit-0.\n"); printf("INT2 interrupt is generated by external signal from DI bit-1.\n"); printf("If you connect DO bit-0 to DI bit-0 and DO bit-1 to DI bit-1,\n"); printf("press any key can generate two interrupts.\n"); printf("One for INT1 and the other for INT2.\n"); printf("Or press ESC for exit\n\n" ); int_count = int2_count=0; if ((card=Register_Card(PCI_7432, card_number)) < 0) { printf("Register_Card Error = %d\n", card); exit(0); } err = DIO_SetDualInterrupt(card, INT1_EXT_SIGNAL, INT2_EXT_SIGNAL, sig1_handler, sig2_handler); if( err != NoError ){ printf(" error from DIO_SetDualInterrupt : %d \n" , err ); goto exit_after_error; } while(1){ temp_char = getch(); if( temp_char == 0x1b ) break; DO_WritePort(card,0, 0x3); usleep(1000); DO_WritePort(card,0, 0x0); } DIO_SetDualInterrupt(card, INT1_DISABLE, INT2_DISABLE, NULL, NULL); exit_after_error: if (card >= 0) Release_Card(card); exit(0); }
int main( void ) { I16 card = -1, card_number = 0, i; U32 input = 0, out_value = 1; if((card = Register_Card(PCI_7250, card_number))<0){ printf("Can't open device file: PCI7250\n"); exit(-1); } printf("open device file successfully!!\n"); do{ clrscr(); printf("PCI-7250 DIO Sample :\n"); printf("\nThe Data to/from DO/DI are shown in the following table:\n"); printf("--------------------------------------------------------\n"); printf(" PCI-7250 : "); DO_WritePort(card, 0, out_value); printf("Do port output = 0x%x\n", (U16)out_value); DI_ReadPort(card, 0, &input); printf(" DI port input = 0x%x\n", (U16)input); for(i=1; i<4; i++){ printf(" PCI-7251#%d : ", i); if(DO_WritePort(card, 0, out_value)==NoError){ printf("\nDo port output = 0x%x\n", (U16)out_value); DI_ReadPort(card, 0, &input); printf("\n DI port input = 0x%x\n", (U16)input); } else printf("None\n"); } printf("--------------------------------------------------------\n"); printf(" Press Enter to stop...\n"); //usleep(200000); out_value = (out_value<<1)%256; if(!out_value) out_value = 1; }while(!kbhit()); if(card>=0){ DO_WritePort(card, 0, 0); Release_Card(card); } return 0; }
void main(void) { I16 card, err, card_num=0; U16 in_value, out_value = 0; printf("This program output data from TTL0 to TTL1.\n"); printf("Please input a card number: "); scanf(" %hd", &card_num); if ((card = Register_Card(PCI_7444, card_num)) <0 ) { printf("Register_Card error=%d", card); exit(1); } err = DIO_PortConfig(card, P7444_TTL0, OUTPUT_PORT); if(err!=NoError) { printf("Input Port Config Error: %d\n",err); exit(1); } err = DIO_PortConfig(card, P7444_TTL1, INPUT_PORT); if(err!=NoError) { printf("Output Port Config Error: %d\n",err); exit(1); } do{ clrscr(); printf ("-------------------------------------------------\n"); err = DO_WritePort(card, P7444_TTL0, out_value); if (err!=NoError) { printf("DO_WritePort error=%d", err); exit(1); } printf(" TTL0 output = 0x%x\n", out_value); err = DI_ReadPort(card, P7444_TTL1, &in_value); if (err!=NoError) { printf("DI_ReadPort error=%d", err); exit(1); } printf(" TTL1 input = 0x%x\n", in_value); printf ("-------------------------------------------------\n"); printf ("\n Press Enter to stop...\n"); usleep(200000); if(out_value < 0xffff) out_value = (out_value + 1); else out_value = 0; } while(!kbhit()); Release_Card(card); }
void sig_handler2(int signo) { if(int2_count<total_count){ DO_WritePort(card,Channel_P3A, buffer[int2_count]); DI_ReadPort(card,Channel_P1A,&in_buffer[int2_count]); int2_count++; //generate INT1 interrupt signal DO_WritePort(card,Channel_P3C,1); DO_WritePort(card,Channel_P3C,0); } else if(int2_count==total_count){ // reset the Timer to stop generate INT2 CTR_Setup(card, 1, RATE_GENERATOR, 0, BIN); CTR_Setup(card, 2, RATE_GENERATOR, 0, BIN); printf("\n\n INT1 Count:%d INT2 Count:%d \n\n\n", int_count, int2_count); printf(" press ENTER for display data \n" ); // this will be catched by getchar() in main() int2_count++; } return; }
int main(int argc, char **argv) { I16 card, err; U16 card_num; U32 DO_Write = 0xffff; U32 DO_Read, DI_Read; printf("This sample write digital data to DO port and read digital value from DI port.\n"); printf("Card Number? "); scanf(" %hd", &card_num); card = Register_Card(PCI_9223, card_num); if(card<0){ printf("Register_Card Error: %d\n", card); exit(1); } do{ /*Write DO port*/ err = DO_WritePort(card, 0, DO_Write); if(err<0){ printf("DO_WritePort Error: %d\n", err); Release_Card(card); exit(1); } /*Read the written data from DO port*/ err = DO_ReadPort(card, 0, &DO_Read); if(err<0){ printf("DO_ReadPort Error: %d\n", err); Release_Card(card); exit(1); } /*Read DI Port*/ err = DI_ReadPort(card, 0, &DI_Read); if(err<0){ printf("DI_ReadPort Error: %d\n", err); Release_Card(card); exit(1); } clrscr(); printf("/*--------------------------------*/\n"); printf(" DO Read Data : %#x\n", DO_Read); printf(" DI Read Data : %#x\n", DI_Read); printf("\n\tPress Enter to exit...\n"); printf("/*--------------------------------*/\n"); DO_Write = (DO_Write==0)? 0xffff: (DO_Write-1); usleep(100000); }while(!kbhit()); Release_Card(card); return 0; }
int main(void) { I16 err; int card_number = 0; U32 input = 0, out_value = 1, pattern = 0; F32 rt = 0.0; printf(" Please input the Card_Index for PCI7260 :"); scanf(" %d", &card_number ); getchar(); if((card = Register_Card(PCI_7260, (I16)card_number))<0){ printf ("Can't open device file: PCI7260 %d\n", card); exit(-1); } printf("open device file successfully!!\n"); err = IdentifyLED_Control (card, 1); GetInitPattern(card, INIT_PTN, &pattern); printf("Init Pattern: %x\n", pattern); DO_WritePort(card, 0, pattern); GetInitPattern(card, EMGSHDN_PTN, &pattern); printf("EMG Shutdown Pattern: %x\n", pattern); err = WDT_Setup(card, 0, 5.0, &rt, wdt_sig_handler); if(err!=NoError){ printf("WDT_Setup err %d!", err); Release_Card(card); exit(1); } err = WDT_Control(card, 0, WDT_ARM); if(err!=NoError){ printf("WDT_Control err %d!", err); Release_Card(card); exit(1); } printf("\nWDT will overflow after %.4f seconds ...\n", rt); getch(); WDT_Control(card, 0, WDT_DISARM); IdentifyLED_Control(card, 0); if(card>=0){ Release_Card(card); } return 0; }
int main(void) { I16 card = -1, err; int card_number = 0; U32 input = 0, out_value = 0x80000000; printf(" Please input the Card_Index for PCI7258 :"); scanf(" %d", &card_number); getchar(); if((card = Register_Card(PCI_7258, (I16)card_number))<0){ printf ("Can't open device file: PCI7258 %d\n", card); exit(-1); } printf("open device file successfully!!\n"); do{ clrscr(); if(out_value==0x80000000) out_value = 1L; printf("PCI-7258 DIO Sample :\n"); printf("\nThe Data to/from DO/DI are shown in the following table:\n"); printf("--------------------------------------------------------\n"); err = DO_WritePort(card, 0, out_value & 0x0FFFF); err = DO_WritePort(card, 1, (out_value >> 16 ) & 0x0FFFF); //printf(" Do port output = 0x%x\n", (U16)out_value); printf(" Do port output = 0x%08lx err=%d\n", (U32)out_value, err); usleep(5000); err = DI_ReadPort(card, 0, &input); //printf(" DI port input = 0x%x\n", (U16)input); printf(" DI port input = 0x%x err=%d\n", (U16)input, err); printf("--------------------------------------------------------\n"); printf(" Press Enter to stop...\n"); //usleep(200000); out_value = out_value<<1; }while(!kbhit()); if(card>=0){ Release_Card(card); } return 0; }
int main(void) { I16 card = -1, err; int card_number = 0; U32 input = 0, out_value = 1, pattern=0; printf(" Please input the Card_Index for PCI7260 :"); scanf(" %d", &card_number); getchar(); if((card = Register_Card(PCI_7260, (I16)card_number))<0){ printf("Can't open device file: PCI7260 %d\n", card); exit(-1); } printf("open device file successfully!!\n"); err = IdentifyLED_Control(card, 1); GetInitPattern(card, INIT_PTN, &pattern); printf("Init Pattern: %x\n", pattern); GetInitPattern(card, EMGSHDN_PTN, &pattern); printf("EMG Shutdown Pattern: %x\n", pattern); do{ clrscr(); printf("PCI-7260 DIO Sample :\n"); printf("\nThe Data to/from DO/DI are shown in the following table:\n"); printf("--------------------------------------------------------\n"); err = DO_WritePort(card, 0, out_value); printf(" Do port output = 0x%x err=%d\n", (U8)out_value, err); usleep(10000); err = DI_ReadPort(card, 0, &input); printf(" DI port input = 0x%x err=%d\n", (U8)input, err); printf("--------------------------------------------------------\n"); printf(" Press Enter to stop...\n"); usleep(200000); out_value = /*(out_value + 1)*/(out_value*2)%256; if(!out_value) out_value = 1; }while(!kbhit()); if(card>=0){ Release_Card(card); } return 0; }
int main( void ) { I16 card=-1, card_number = 0; U32 input = 0, out_value = 1, i=0; if ((card=Register_Card(PCI_7452, card_number)) < 0) { printf ("Can't open device file: PCI7452\n"); exit(-1); } printf ("open device file successfully!!\n"); do { clrscr(); printf ("PCI-7452 DIO Sample :\n\n"); printf ("The Data to/from DO/DI are shown in the following table:\n"); printf ("--------------------------------------------------------\n"); for(i=0; i<4; i++) { DO_WritePort(card, i, out_value); printf(" Do port%d output = 0x%lx\n", i, out_value); usleep(100); DI_ReadPort(card, i, &input); printf(" DI port%d input = 0x%lx\n", i, input); } printf ("--------------------------------------------------------\n"); printf (" Press Enter to stop...\n"); usleep(100000); out_value = (out_value * 2) % ((1<<31) + 1); if(!out_value) out_value = 1; }while( !kbhit() ); if(card>=0) { Release_Card(card); } return 0; }
int main(int argc, char **argv) { I16 err; U16 card_num=0; //U32 vi; U32 DIRead,DOWrite; //BOOLEAN fStop; U32 COSEventOutLen = 100; //100 system clock - 100 * 8 ns printf("This sample performs change of state functionality.\n"); printf("DIO Port A is configured as a DO port while Port B\n"); printf("is configured as a DI Port. Signal will be asserted\n"); printf("and a %ld ns pulse will be generated to AFI0 while\n", 8*COSEventOutLen); printf("the DI state is changed.\n"); printf("Card Number? "); scanf(" %hd", &card_num); int_count=0; /*Open and Initialize Device*/ card = Register_Card(PCI_7350, card_num); if(card<0){ printf("Register_Card Error: %d\n", card); exit(1); } /*Configure 7350 DIO Port*/ err = DIO_PortConfig(card, P7350_DIO_A, OUTPUT_PORT); if(err<0){ printf("DIO_PortConfig Port_A Error: %d\n", err); Release_Card(card); exit(1); } err = DIO_PortConfig(card, P7350_DIO_B, INPUT_PORT); if(err<0){ printf("DIO_PortConfig Port_B Error: %d\n", err); Release_Card(card); exit(1); } DO_WritePort(card, P7350_DIO_A, 0); //usleep(1000); /* * Setup COS for Port B */ //err = DIO_SetCOSInterrupt32(card, 0, 0xff00, &COS_Event/*, 0*/); err = DIO_SetCOSInterrupt32(card, 0, 0xff00, sig_handler); if(err<0){ printf("DIO_SetCOSInterrupt32 Error: %d\n", err); Release_Card(card); exit(1); } /* * Set COS event out to AFI port */ err = DIO_7350_AFIConfig(card, P7350_AFI_0, 1, P7350_AFI_COSTrigOut, COSEventOutLen); if(err<0){ printf("DIO_7350_AFIConfig Port_A Error: %d\n", err); Release_Card(card); exit(1); } do{ /* * DO output to Port A/C */ //printf("\nOutput Data?"); //scanf(" %lx", &vi); usleep(500000); clrscr(); printf("This sample performs change of state functionality.\n"); printf("DIO Port A is configured as a DO port while Port B\n"); printf("is configured as a DI Port. Signal will be asserted\n"); printf("and a %ld ns pulse will be generated to AFI0 while\n", 8*COSEventOutLen); printf("the DI state is changed.\n\n\n"); if((out_Val)%4==0||(out_Val)%4==1){ DO_WritePort(card, P7350_DIO_A, 0/*vi&0xff*/);DOWrite=0;} else{ DO_WritePort(card, P7350_DIO_A, 1/*vi&0xff*/);DOWrite=1;} //out_Val = (out_Val+1)%2; //DO_WritePort(card, P7350_DIO_A, out_Val/*vi&0xff*/); usleep(1000); //DO_WritePort(card, P7350_DIO_A, vi&0xff); DI_ReadPort(card, P7350_DIO_B, &DIRead); out_Val++; printf("Write to Port A: 0x%lx; Read from Port B: 0x%lx;\n\n\n", DOWrite/*vi&0xff*/, DIRead); //printf("Write to Port A: 0x%lx; Read from Port B: 0x%lx;\n", vi&0xff, DIRead); printf("Press Enter to Quit......\n"); //fStop = getch(); }while(!kbhit()/*(fStop!='q')&&(fStop!='Q')*/); err = DIO_SetCOSInterrupt32(card, 0, 0, NULL); if(err<0){ printf("DIO_SetCOSInterrupt32 Error: %d\n", err); } err = DIO_7350_AFIConfig(card, P7350_AFI_0, 0, 0, 0); if(err<0){ printf("DIO_7350_AFIConfig Error: %d\n", err); } //printf("Press any key to exit...\n\n"); //getch(); Release_Card(card); return 0; }
int main(int argc, char **argv) { I16 card, err; U16 card_num; U32 DI_Value0; U32 DI_Value1; U32 DO_Value = 0; U32 DO_Read0; U32 DO_Read1; printf("This sample perform DIO with polling mode.\n"); printf("Port A/C are configured as DO ports\n"); printf("while port B/D are configured as DI ones.\n"); printf("You can connect port A-C, and B-D to test this sample.\n\n"); printf("Card Number? "); scanf(" %hd", &card_num); /* * Open and Initialize Device */ card = Register_Card(PCI_7350, card_num); if(card<0){ printf("Register_Card Error: %d\n", card); exit(1); } /* * Configure 7350 DIO Port Direction (Input or Output) */ err = DIO_PortConfig(card, P7350_DIO_A, OUTPUT_PORT); if(err<0){ printf("DIO_PortConfig Port_A Error: %d\n", err); Release_Card(card); exit(1); } err = DIO_PortConfig(card, 1, INPUT_PORT); if(err<0){ printf("DIO_PortConfig Port_B Error: %d\n", err); Release_Card(card); exit(1); } err = DIO_PortConfig(card, P7350_DIO_C, OUTPUT_PORT); if(err<0){ printf("DIO_PortConfig Port_C Error: %d\n", err); Release_Card(card); exit(1); } err = DIO_PortConfig(card, P7350_DIO_D, INPUT_PORT); if(err<0){ printf("DIO_PortConfig Port_D Error: %d\n", err); Release_Card(card); exit(1); } /* * Configure DIO Voltage Level */ err = DIO_VoltLevelConfig(card, P7350_PortDIO, VoltLevel_3R3); if(err<0){ printf("DIO_7350_SetVoltLevel Error: %d\n", err); Release_Card(card); exit(1); } else { printf("DIO_7350_SetVoltLevel ok!"); } /* * Read/Write Control */ do{ clrscr(); /*Write Port A*/ err = DO_WritePort(card, P7350_DIO_A, DO_Value); if(err<0){ printf("DO_WritePort Port A Error: %d\n", err); Release_Card(card); exit(1); } /*Write Port C*/ err = DO_WritePort(card, P7350_DIO_C, 255-DO_Value); if(err<0){ printf("DO_WritePort Port C Error: %d\n", err); Release_Card(card); exit(1); } usleep(1000); /*Read Port B*/ err = DI_ReadPort(card, P7350_DIO_B, &DI_Value0); if(err<0){ printf("DI_ReadPort Port B Error: %d\n", err); Release_Card(card); exit(1); } /*Read Port D*/ err = DI_ReadPort(card, P7350_DIO_D, &DI_Value1); if(err<0){ printf("DI_ReadPort Port D Error: %d\n", err); Release_Card(card); exit(1); } /*Read Back Port A*/ err = DO_ReadPort(card, P7350_DIO_A, &DO_Read0); if(err<0){ printf("DO_ReadPort Port A Error: %d\n", err); Release_Card(card); exit(1); } /*Read Back Port C*/ err = DO_ReadPort(card, P7350_DIO_C, &DO_Read1); if(err<0){ printf("DO_ReadPort Port C Error: %d\n", err); Release_Card(card); exit(1); } printf("-----------------------------------------\n"); printf(" DO Write Port Port A Port C\n"); printf(" DO Write Data 0x%lx 0x%lx\n\n", DO_Value, 255-DO_Value); printf(" DO Read Port Port A Port C\n"); printf(" DO Read Data 0x%lx 0x%lx\n\n", DO_Read0, DO_Read1); printf(" DI Read Port Port B Port D\n"); printf(" DI Read Data 0x%lx 0x%lx\n\n", DI_Value0, DI_Value1); printf(" Press Enter to stop...\n"); printf("-----------------------------------------\n"); if(++DO_Value==256) DO_Value = 0; usleep(1000); }while(!kbhit()); printf("Press any key to exit...\n"); getch(); Release_Card(card); return 0; }
void AU9525Tester::OnStartTest() { // TODO: Add your control notification handler code here UpdateData(TRUE); // m_strResult = ""; // m_strTestInformation = ""; UpdateData(FALSE); // GetDlgItem(IDC_BUTTON_START)->EnableWindow(FALSE); // SetTimer(ID_CLOCK,10000,NULL); long t1; // test cycle // EndLess contorl loop CString StrOutput; StrOutput="Ready"; CString ChipName,StrInput; MSG msg; COleVariant Buf; do{ time(&t1); // get time ChipName=""; //============================================ // Get ChipName //============================================ do { m_Comm.SetOutput(COleVariant(StrOutput)); // Send Ready Sleep(10); Buf=m_Comm.GetInput(); // get chip name ChipName=ChipName + (CString)(Buf.bstrVal); // DoEvents while( ::PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ) { ::GetMessage( &msg, NULL, 0, 0 ); ::TranslateMessage( &msg ); ::DispatchMessage( &msg ); } } while ((ChipName!="AU6710ASF22") && (AllenStop==0)); // m_SpeedError.SetBkColor(RGB(255,255,255)); // initail interface // m_LedFail.SetBkColor(RGB(255,255,255)); m_UnknowDevice.SetBackColor(RGB(255,255,255)); m_Slot0.SetBackColor(RGB(255,255,255)); m_Slot1.SetBackColor(RGB(255,255,255)); m_TestResult.SetBackColor(RGB(255,255,255)); m_TestResult.SetWindowText("Wait for Testing"); // set label UI // m_strResult = ""; // m_strTestInformation = ""; // DO_WritePort(card, Channel_P1A, 0x0); // set power on Sleep(2000); StartTest(); // m_Infor.LineScroll(m_Infor.GetLineCount()); DO_WritePort(card, Channel_P1A, 0xFF); while( ::PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ) { ::GetMessage( &msg, NULL, 0, 0 ); ::TranslateMessage( &msg ); ::DispatchMessage( &msg ); } } while (AllenStop==0); }