Add GETPERMITTEDSDIVS command to gpib server

master
Timothy Pearson 11 years ago
parent de23e8f184
commit 260c25ebe5

@ -549,6 +549,27 @@ void GPIBSocket::commandLoop() {
writeEndOfFrame();
}
}
else if (m_instrumentCommand == "GETPERMITTEDSDIVS") { // Want to get permitted seconds/div settings
double* permitted_array;
int permitted_count;
TQ_INT32 value;
ds >> value;
if (scope_get_permitted_seconds_div_settings(&permitted_count, &permitted_array, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket) == 0) {
long i;
TQDoubleList permittedValues;
for (i=0; i<permitted_count; i++) {
permittedValues.append(permitted_array[i]);
}
free(permitted_array);
ds << TQString("ACK");
ds << permittedValues;
writeEndOfFrame();
}
else {
ds << TQString("NCK");
writeEndOfFrame();
}
}
else {
printf("[WARNING] Received unknown command %s from host %s\n\r", m_instrumentCommand.ascii(), m_remoteHost.ascii()); fflush(stdout);
ds << TQString("NCK");
@ -1116,20 +1137,20 @@ int GPIBServer::readConfig() {
printf("[FAIL] Unable to open serial device %s\n\r", m_serialDevice.ascii()); fflush(stdout);
return 1;
}
tcgetattr(m_serialDeviceSocket, &oldtio); // Save current port settings
bzero(&newtio, sizeof(newtio));
newtio.c_cflag = m_serialBaud | CS8 | CLOCAL | CREAD;
newtio.c_iflag = IGNPAR;
newtio.c_oflag = 0;
// Set input mode (non-canonical, no echo,...)
newtio.c_lflag = 0;
newtio.c_cc[VTIME] = 0; // Inter-character timer unused
newtio.c_cc[VMIN] = 0; // Blocking read unused
tcflush(m_serialDeviceSocket, TCIFLUSH);
tcsetattr(m_serialDeviceSocket, TCSANOW, &newtio);

@ -378,7 +378,7 @@ int scope_get_acquisition(int * retval, const char * scopeType, int gpibDevice)
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Trying to read %i bytes from GPIB device...\n", max_num_bytes);
#endif
ai = gpib_read_array(gpibDevice, max_num_bytes, floatstring);
if (ai == -1) {
return 1;
@ -387,7 +387,7 @@ int scope_get_acquisition(int * retval, const char * scopeType, int gpibDevice)
floatstring[ai]=0;
*retval = atoi(floatstring);
}
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Read %li bytes from GPIB device\n", ai);
#endif
@ -479,7 +479,7 @@ int scope_get_channel_state(int * retval, int desired_channel, const char * scop
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Trying to read %i bytes from GPIB device...\n", max_num_bytes);
#endif
ai = gpib_read_array(gpibDevice, max_num_bytes, floatstring);
if (ai == -1) {
return 1;
@ -488,7 +488,7 @@ int scope_get_channel_state(int * retval, int desired_channel, const char * scop
floatstring[ai]=0;
*retval = atoi(floatstring);
}
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Read %li bytes from GPIB device\n", ai);
#endif
@ -563,7 +563,7 @@ int scope_get_trigger_channel(int * retval, const char * scopeType, int gpibDevi
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Trying to read %i bytes from GPIB device...\n", max_num_bytes);
#endif
ai = gpib_read_array(gpibDevice, max_num_bytes, floatstring);
if (ai == -1) {
return 1;
@ -582,7 +582,7 @@ int scope_get_trigger_channel(int * retval, const char * scopeType, int gpibDevi
return -1;
}
}
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Read %li bytes from GPIB device\n", ai);
#endif
@ -658,7 +658,7 @@ int scope_get_trigger_level(double * retval, const char * scopeType, int gpibDev
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Trying to read %i bytes from GPIB device...\n", max_num_bytes);
#endif
ai = gpib_read_array(gpibDevice, max_num_bytes, floatstring);
if (ai == -1) {
return 1;
@ -667,7 +667,7 @@ int scope_get_trigger_level(double * retval, const char * scopeType, int gpibDev
floatstring[ai]=0;
*retval = atof(floatstring);
}
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Read %li bytes from GPIB device\n", ai);
#endif
@ -990,7 +990,7 @@ int scope_get_channel_volts_div(double * retval, int desired_channel, const char
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Trying to read %i bytes from GPIB device...\n", max_num_bytes);
#endif
ai = gpib_read_array(gpibDevice, max_num_bytes, floatstring);
if (ai == -1) {
return 1;
@ -999,7 +999,7 @@ int scope_get_channel_volts_div(double * retval, int desired_channel, const char
floatstring[ai]=0;
*retval = atof(floatstring);
}
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Read %li bytes from GPIB device\n", ai);
#endif
@ -1057,7 +1057,7 @@ int scope_get_channel_seconds_div(double * retval, int desired_channel, const ch
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Trying to read %i bytes from GPIB device...\n", max_num_bytes);
#endif
ai = gpib_read_array(gpibDevice, max_num_bytes, floatstring);
if (ai == -1) {
return 1;
@ -1066,7 +1066,7 @@ int scope_get_channel_seconds_div(double * retval, int desired_channel, const ch
floatstring[ai]=0;
xincr = atof(floatstring);
}
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Read %li bytes from GPIB device\n", ai);
#endif
@ -1086,7 +1086,7 @@ int scope_get_channel_seconds_div(double * retval, int desired_channel, const ch
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Trying to read %i bytes from GPIB device...\n", max_num_bytes);
#endif
ai = gpib_read_array(gpibDevice, max_num_bytes, floatstring);
if (ai == -1) {
return 1;
@ -1095,7 +1095,7 @@ int scope_get_channel_seconds_div(double * retval, int desired_channel, const ch
floatstring[ai]=0;
*retval = ((atof(floatstring)*xincr)/scope_get_number_of_vertical_divisions(scopeType, gpibDevice));
}
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Read %li bytes from GPIB device\n", ai);
#endif
@ -1151,7 +1151,7 @@ int scope_get_channel_sample_count(unsigned long * retval, int desired_channel,
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Trying to read %i bytes from GPIB device...\n", max_num_bytes);
#endif
ai = gpib_read_array(gpibDevice, max_num_bytes, floatstring);
if (ai == -1) {
return 1;
@ -1160,7 +1160,7 @@ int scope_get_channel_sample_count(unsigned long * retval, int desired_channel,
floatstring[ai]=0;
*retval = atof(floatstring);
}
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Read %li bytes from GPIB device\n", ai);
#endif
@ -1200,7 +1200,7 @@ int scope_get_probe_attenuation_multiplier(double * retval, int desired_channel,
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Trying to read %i bytes from GPIB device...\n", max_num_bytes);
#endif
ai = gpib_read_array(gpibDevice, max_num_bytes, floatstring);
if (ai == -1) {
return 1;
@ -1209,7 +1209,7 @@ int scope_get_probe_attenuation_multiplier(double * retval, int desired_channel,
floatstring[ai]=0;
*retval = atof(floatstring);
}
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Read %li bytes from GPIB device\n", ai);
#endif
@ -1249,4 +1249,49 @@ int scope_get_permitted_volts_div_settings_at_1x(int * number_of_values, double
else {
return -1;
}
}
}
int scope_get_permitted_seconds_div_settings(int * number_of_values, double ** retarray, const char * scopeType, int gpibDevice) {
if (strcmp("HP54600OS", scopeType) == 0) {
// FIXME
// Not supported (yet)
return -1;
}
else if (strcmp("TDS744AOS", scopeType) == 0) {
*number_of_values = 28;
double* values = (double*)malloc(sizeof(double)*(*number_of_values));
values[0] = 1.25e-8;
values[1] = 2.5e-8;
values[2] = 5e-8;
values[3] = 1e-7;
values[4] = 2e-7;
values[5] = 5e-7;
values[6] = 1e-6;
values[7] = 2e-6;
values[8] = 5e-6;
values[9] = 1e-5;
values[10] = 2e-5;
values[11] = 5e-5;
values[12] = 1e-4;
values[13] = 2e-4;
values[14] = 5e-4;
values[15] = 1e-3;
values[16] = 2e-3;
values[17] = 5e-3;
values[18] = 1e-2;
values[19] = 2e-2;
values[20] = 5e-2;
values[21] = 1e-1;
values[22] = 2e-1;
values[23] = 5e-1;
values[24] = 1e0;
values[25] = 2e0;
values[26] = 5e0;
values[27] = 1e1;
*retarray = values;
return 0;
}
else {
return -1;
}
}

@ -51,4 +51,5 @@ int scope_get_channel_volts_div(double * retval, int desired_channel, const char
int scope_get_channel_seconds_div(double * retval, int desired_channel, const char * scopeType, int gpibDevice);
int scope_get_channel_sample_count(unsigned long * retval, int desired_channel, const char * scopeType, int gpibDevice);
int scope_get_probe_attenuation_multiplier(double * retval, int desired_channel, const char * scopeType, int gpibDevice);
int scope_get_permitted_volts_div_settings_at_1x(int * number_of_values, double ** retarray, const char * scopeType, int gpibDevice);
int scope_get_permitted_volts_div_settings_at_1x(int * number_of_values, double ** retarray, const char * scopeType, int gpibDevice);
int scope_get_permitted_seconds_div_settings(int * number_of_values, double ** retarray, const char * scopeType, int gpibDevice);
Loading…
Cancel
Save