#include "commdrv.h" #include #include #include const int base = 0x300; void ErrorCheck (char checkstring[255]) { char Error; Error = strcmp(checkstring, "??ERROR!"); if (Error == 0) { puts("A communications error has occurred!"); exit(Error == 0);} } void main(void) { char retstring[255]; char check; clrscr(); /*H*/ initCommCard(base, 9600); printf("Press a key to say hello to the Pod...\n"); getch(); writePod(base,"H"); readPod(base, retstring); printf("%s\n", retstring); check = strcmp(retstring, "??ERROR!"); if (check == 0) { puts("A communications error has occurred!"); puts("Baud rate must be set at 9600."); exit(check == 0); } /*M*/ printf("Press a key to configure all bits for input...\n"); getch(); /*bits 0-7 output*/ writePod(base,"ML00"); readPod(base, retstring); ErrorCheck (retstring); delay (50); /*bits 8-F output*/ writePod(base,"MM00"); readPod(base, retstring); check = strcmp(retstring, "??ERROR!"); ErrorCheck (retstring); delay(50); /*bits 10-17 output*/ writePod(base,"MH00"); readPod(base, retstring); ErrorCheck (retstring); /*I*/ printf("Press a key to read all the bits...\n"); getch(); /*read all bits*/ writePod(base, "I"); readPod(base, retstring); ErrorCheck (retstring); printf("The twenty-four bits are %s\n", retstring); printf("Press a key to read bit 0F...\n"); getch(); /*read bit 15*/ writePod(base, "I0F"); readPod(base, retstring); ErrorCheck (retstring); printf("Bit 0F is %s\n", retstring); printf("Press a key to read bits 0-7...\n"); getch(); /*read bits 0-7*/ writePod(base,"IL"); readPod(base, retstring); ErrorCheck (retstring); printf("Bits 0-7 are %s\n",retstring); /*M*/ printf("Press a key to configure all bits as outputs...\n"); getch(); /*bits 0-7 input*/ writePod(base, "MLFF"); readPod(base,retstring); ErrorCheck (retstring); delay(50); /*bits 8-F input*/ writePod(base, "MMFF"); readPod(base,retstring); ErrorCheck (retstring); delay(50); /*bits 10-17 input*/ writePod(base, "MHFF"); readPod(base,retstring); ErrorCheck (retstring); /*F*/ printf("Press a key to create a Free-Running square wave (bit 0F period 10)...\n"); getch(); /*Free Running square wave on bit 0F with period 10*/ writePod(base, "f0F,10"); readPod(base, retstring); ErrorCheck (retstring); /*C*/ printf("Press a key to read free-run status and reset counter 0F...\n"); getch(); /*read free-run status and reset counter 0F*/ writePod(base,"c0F"); readPod(base, retstring); ErrorCheck (retstring); printf("The value of the digital input counter is %s\n", retstring); /*R*/ printf("Press a key to end free run...\n"); getch(); /*turn off free run*/ writePod(base, "r0F"); readPod(base, retstring); ErrorCheck (retstring); /*S*/ printf("Press a key to set time base to 1 KHz...\n"); getch(); /*set time base*/ writePod(base, "S039A"); delay(100); /*O*/ printf("Press a key to write a 1 to bit 2...\n"); getch(); /*write a zero to bit 2*/ writePod(base, "O2-"); readPod(base, retstring); ErrorCheck (retstring); printf("Press a key to write a 1 to bit 3...\n"); getch(); /*write a one to bit 3*/ writePod(base, "O3+"); readPod(base, retstring); ErrorCheck (retstring); puts("\n"); puts("\n"); printf(" You have completed the RIOD-24 sample program.\n"); }