int main(int argc, char **argv) { HANDLE hDevice; u6CalibrationInfo caliInfo; //Opening first found U6 over USB if( (hDevice = openUSBConnection(-1)) == NULL ) goto done; //Getting calibration information from U6 if( getCalibrationInfo(hDevice, &caliInfo) < 0 ) goto close; if( ConfigIO_example(hDevice) != 0 ) goto close; //Stopping any previous streams StreamStop(hDevice); if( StreamConfig_example(hDevice) != 0 ) goto close; if( StreamStart(hDevice) != 0 ) goto close; StreamData_example(hDevice, &caliInfo); StreamStop(hDevice); close: closeUSBConnection(hDevice); done: return 0; }
int main(int argc, char **argv) { HANDLE hDevice; //Opening first found UE9 over USB if( (hDevice = openUSBConnection(-1)) == NULL) return 1; timerCounter_example(hDevice); closeUSBConnection(hDevice); return 0; }
int main(int argc, char **argv) { HANDLE hDevice; ue9CalibrationInfo caliInfo; //Opening first found UE9 over USB if( (hDevice = openUSBConnection(-1)) == NULL ) goto done; //Getting calibration information from UE9 if( getCalibrationInfo(hDevice, &caliInfo) < 0 ) goto close; allIO(hDevice, &caliInfo); close: closeUSBConnection(hDevice); done: return 0; }
int labjackSetup(){ long int localID=-1; long int count=0; long int error=0; /* Open first found U6 over USB */ printf("opening usb .... "); while (count < 5) { if( (hU6 = openUSBConnection(localID)) == NULL){ count++; printf("Opening failed; reseting and attempting %li of 5 more times \n",count); printf ("....U6 device reset \n"); resetU6(0x01); // 0x00 = soft reset; 0x01 = reboot sleep (2); resetU6(0x01); // 0x00 = soft reset; 0x01 = reboot sleep (2); if (count > 5) return 0; } else { count = 5; } } printf("opened usb\n"); /* Get calibration information from U6 */ printf("getting calib .... "); error = getCalibrationInfo(hU6, &caliInfo); if(error != 0){ printf("\n%li - %s\n",error, errormsg[error]); closeUSBConnection(hU6); return 0; } printf("got calib \n"); return; }
//main int main (int argc, const char * argv[]) { bool retval; HANDLE ljHandle; printf("Main\n"); if( (ljHandle = openUSBConnection(-1)) == NULL) { printf("Error\n"); return -1; } retval = ljU6ConfigPorts(ljHandle); long long i; long long t1,t2; long state; long long savedEl[STATSN+1]; long long tStart; int savedN=0; double meanEl; int iM; int r; double maxEl; //eDO(ljHandle, LJU6_REWARD_FIO, 0); tStart = timeUS(); for (i=0; true; i++) { t1 = timeUS(); // DI r = eDI(ljHandle, 0, &state); if (r < 0) { printf("eDI call failed. Exiting"); return r; } // // DO high //usleep(1000); //r = eDO(ljHandle, 1, 1); //if (r < 0) { // printf("eDO high call failed. Exiting"); // return r; //} //// DO low //usleep(2000); //r = eDO(ljHandle, 1, 0); //if (r < 0) { // printf("eDO low call failed. Exiting"); // return r; //} t2 = timeUS(); if (i % 100 == 0) { printf("Elapsed %lld us, iter %10lld\n", t2-t1, i); fflush(stdout); } savedEl[savedN] = t2-t1; savedN++; // stats, every STATSN trials if (i % STATSN == 0 && i>0) { // not the first time meanEl = 0; maxEl = 0; for (iM=0; iM<STATSN; iM++) { meanEl = meanEl + savedEl[iM]; if (savedEl[iM] > maxEl) { maxEl = savedEl[iM]; } } meanEl = meanEl/STATSN; savedN = 0; printf("** Mean %8.1f max %8.1f totalElapsedUs %lld\n", meanEl, maxEl, timeUS()-tStart); } //while (timeUS() - t1 < 1000) { // usleep(1000); //} } closeUSBConnection(ljHandle); return 0; }