int lecroy_wait_all_averages(VXI11_CLINK * clink, unsigned long timeout) { char cmd[256]; char buf[256]; int chan_on[4]; int mask; int l; int inr = 0; int old_inr = 0; int test = 0; /* Go through all maths channels, see if they're turned on or not */ for (l = 0; l < 4; l++) { sprintf(cmd, "F%d:TRACE?", l + 1); memset(buf, 0, 256); vxi11_send_and_receive(clink, cmd, buf, 256, timeout); if (strstr(buf, "ON") != NULL) { chan_on[l] = 1; } else { chan_on[l] = 0; } } /* Now investigate which maths channels (that are turned on) are averaging */ l = 0; while (l < 4) { if (chan_on[l] == 1) { sprintf(cmd, "F%d:DEF?", l + 1); memset(buf, 0, 256); vxi11_send_and_receive(clink, cmd, buf, 256, timeout); if (strstr(buf, "AVG") == NULL) { chan_on[l] = 0; } } l++; } /* make the appropriate mask */ mask = (chan_on[0] * 256) + (chan_on[1] * 512) + (chan_on[2] * 1024) + (chan_on[3] * 2048); while (test == 0) { inr = (int)vxi11_obtain_long_value_timeout(clink, "INR?", timeout); old_inr = old_inr | inr; if ((old_inr & mask) == mask) test = 1; else test = 0; } return 0; }
long vxi11_obtain_long_value(CLINK *clink, const char *cmd, unsigned long timeout) { char buf[50]; /* 50=arbitrary length... more than enough for one number in ascii */ memset(buf, 0, 50); if (vxi11_send_and_receive(clink, cmd, buf, 50, timeout) != 0) { printf("Returning 0\n"); return 0; } return strtol(buf, (char **)NULL, 10); }
double vxi11_obtain_double_value(CLINK *clink, const char *cmd, unsigned long timeout) { char buf[50]; /* 50=arbitrary length... more than enough for one number in ascii */ double val; memset(buf, 0, 50); if (vxi11_send_and_receive(clink, cmd, buf, 50, timeout) != 0) { printf("Returning 0.0\n"); return 0.0; } val = strtod(buf, (char **)NULL); return val; }
int lecroy_get_bytes_per_point(VXI11_CLINK * clink) { char buf[256]; memset(buf, 0, 256); vxi11_send_and_receive(clink, "COMM_FORMAT?", buf, 256, VXI11_READ_TIMEOUT); if (strstr(buf, "WORD") != NULL) return 2; else return 1; }
int lecroy_get_segmented_status(VXI11_CLINK * clink) { char buf[256]; int segmented_status; vxi11_send_and_receive(clink, "VBS? 'Return=app.Acquisition.Horizontal.SampleMode'", buf, 256, VXI11_READ_TIMEOUT); segmented_status = strncmp(buf, "Sequence", 8); if (segmented_status == 0) return 1; else return 0; }
/* Annoyingly, INSP? queries don't just return a number, they also return the * paramater name you want to inspect, followed by spaces, a ":", then a space. * In order to parse these, we look for the ":" */ double lecroy_obtain_insp_double(VXI11_CLINK * clink, const char *cmd, unsigned long timeout) { char buf[256]; /* 256=arbitrary length... */ int l = 0; memset(buf, 0, 256); if (vxi11_send_and_receive(clink, cmd, buf, 256, timeout) != 0) { printf("Error: lecroy_obtain_insp_double returning 0.0\n"); return 0.0; } while ((buf[l] != ':') && (l < 256)) l++; if (l == 256) { printf ("Error: problem parsing returned string in lecroy_obtain_insp_double. String:\n"); printf("%s\nReturning 0.0\n", buf); return 0.0; } return strtod(buf + l + 2, (char **)NULL); }