//*********************************************// // i-87123 for LinPAC series test program // // Controll DI/DO with SDO message // // // //*********************************************// #include #include #include "msw.h" #include #include "..\lib\I87123.h" char Kbhit(void){ int n=0; ioctl(0,FIONREAD,&n); if(n) return kbhit(); return n; } int main(void) { int ret; int slot,baud; char command; printf("\r\n"); printf("/************************/\r\n"); printf("/*Library Version = %.02f*/\r\n",I87123_GetVersion()); printf("/************************/\r\n"); printf("i-87123 slot(0~7):"); scanf("%d",&slot); printf("0:10Kbps 4:250Kbps\r\n"); printf("1:20Kbps 5:500Kbps\r\n"); printf("2:50Kbps 6:800Kbps\r\n"); printf("3:125Kbps 7:1000Kbps\r\n"); printf("i-87123 baud(0~7):"); scanf("%d",&baud); getch(); ret = Open_Slot(0); if(ret){ printf("Open_Slot error, Error Code = %d\r\n",ret); printf("Press any key to exit program"); getch(); return 0; } ChangeToSlot(slot); // change slot to i-87123 ret = I87123_Configure((unsigned char)baud); // Configure i-87123 Baudrate if(ret){ printf("Configure error, Error Code = %d\r\n",ret); printf("Press any key to exit program"); Close_Slot(0); getch(); return 0; } else{ printf("Configure OK\r\n"); } printf("a. Add Node:\r\n"); printf("b. Remove Node:\r\n"); printf("c. Read DI:\r\n"); printf("d. Write DO:\r\n"); printf("q. Shutdown and exit:\r\n:"); while(1){ { int i; unsigned char node; unsigned short cobid; unsigned char len; unsigned char rdata[40]; ret = I87123_MsgResponse(&node, &cobid, &len, rdata); // Receive response message if(ret != I87123_EMPTY){ if(ret == I87123_OK){ // Receive PDO response message printf("\rPDO: "); printf("[%X] ",cobid); for(i=0;i