Add GETHORIZTIMEBASE to gpib server

master
Timothy Pearson 10 years ago
parent 260c25ebe5
commit 31f91d555b

@ -285,6 +285,18 @@ void GPIBSocket::commandLoop() {
writeEndOfFrame();
}
}
else if (m_instrumentCommand == "GETHORIZTIMEBASE") { // Want horizontal timebase
double timebase;
if (scope_get_timebase(&timebase, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket) == 0) {
ds << TQString("ACK");
ds << timebase;
writeEndOfFrame();
}
else {
ds << TQString("NCK");
writeEndOfFrame();
}
}
else if ((m_instrumentCommand == "GETCHANNELTRACE")) { // Want channel trace
TQ_INT32 value;
ds >> value;

@ -273,6 +273,55 @@ int scope_set_timebase(float desired_timebase,const char * scopeType, int gpibDe
}
}
int scope_get_timebase(double * retval, const char * scopeType, int gpibDevice) {
char floatstring[1024];
long ai;
int max_num_bytes = 0;
if (strcmp("HP54600OS", scopeType) == 0) {
// FIXME
// Not supported (yet)
return -1;
}
else if (strcmp("TDS744AOS", scopeType) == 0) {
// Send request
printf("[INFO] Getting scope timebase\n\r");
sprintf(falpha,"HORIZONTAL:MAIN:SCALE?");
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
max_num_bytes = 24; // Request more bytes than are possible to ensure no bytes are left behind
}
else {
return 2;
}
// Read response
#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;
}
else {
floatstring[ai]=0;
*retval = atof(floatstring)*10;
}
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Read %li bytes from GPIB device\n", ai);
#endif
return 0;
}
else {
return -1;
}
}
int scope_set_volts_div(int desired_channel, double desired_volts, const char * scopeType, int gpibDevice) {
if ((strcmp("HP54600OS", scopeType) == 0) || (strcmp("TDS744AOS", scopeType) == 0)) {
printf("[INFO] Setting scope volts/div on channel %d to %E\n\r", desired_channel, desired_volts);

@ -33,6 +33,7 @@ int scope_get_screenshot(const char * scopeType, int gpibDevice);
int scope_get_screenshot_stage2(const char * scopeType, int gpibDevice);
int scope_perform_initial_setup(const char * scopeType, int gpibDevice);
int scope_set_timebase(float desired_timebase,const char * scopeType, int gpibDevice);
int scope_get_timebase(double * retval, const char * scopeType, int gpibDevice);
int scope_set_volts_div(int desired_channel, double desired_volts, const char * scopeType, int gpibDevice);
int scope_set_acquisition(int status,const char * scopeType, int gpibDevice);
int scope_get_acquisition(int * retval, const char * scopeType, int gpibDevice);

Loading…
Cancel
Save