static VALUE method_write_all_digital(VALUE self, int value) { if (check_connection(self)) { value = NUM2INT(value); if (WriteAllDigital(value) != -1) return Qtrue; printf("K8055 returned an error.\n"); return Qfalse; } }
int main (int argc,char *params[]) { int i,result[3]; unsigned char d=0; int a1=0,a2=0; unsigned short c1=0, c2=0; unsigned long int start,mstart=0,lastcall=0; start = time_msec(); /* Load parameters If parameters are valid continue */ if (read_param(argc,params)) { /* Initialise USB system and enable debug mode if ( debug ) usb_set_debug(2); */ /* Search the device */ if ( OpenDevice(ipid)<0 ) { printf("Could not open the k8055 (port:%d)\nPlease ensure that the device is correctly connected.\n",ipid); return (-1); } else { if ( resetcnt1 ) ResetCounter(1); if ( resetcnt2 ) ResetCounter(2); if ( dbt1 != -1 ) SetCounterDebounceTime(1,dbt1); if ( dbt2 != -1 ) SetCounterDebounceTime(2,dbt1); mstart = time_msec(); // Measure start for (i=0; i<numread; i++) { if ( delay ) { // Wait until next measure while ( time_msec()-mstart < i*delay ); } ReadAllAnalog(&a1,&a2); d=ReadAllDigital(); c1=ReadCounter(1); c2=ReadCounter(2); lastcall = time_msec(); printf("%d;%d;%d;%d;%d;%d\n", (int)(lastcall-start),d, (int)a1, (int)a2,c1,c2 ); } if (debug && ((ia1!=-1)||(ia2!=-1)||(id8!=-1))) printf("Set "); if (ia1!=-1){ result[0]=OutputAnalogChannel(1,ia1); if (debug) printf("analog1:%d ",result[0]);} if (ia2!=-1){ result[1]=OutputAnalogChannel(2,ia2); if (debug) printf("analog2:%d ",result[1]);} if (id8!=-1){ result[2]=WriteAllDigital((long)id8); if (debug) printf("digital:%d",result[2]);} if (debug) printf("\n"); CloseDevice(); } } return 0; }