diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2014-04-24 04:19:56 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2014-04-24 04:19:56 -0500 |
commit | 31f91d555b16487cc1670cbfa8c18b2f14993d57 (patch) | |
tree | 54c88bd6a6c820e4d0a564ce730efed268ae59a6 | |
parent | 260c25ebe511f9a3ee6454c4e897947fc8eef1f0 (diff) | |
download | ulab-31f91d555b16487cc1670cbfa8c18b2f14993d57.tar.gz ulab-31f91d555b16487cc1670cbfa8c18b2f14993d57.zip |
Add GETHORIZTIMEBASE to gpib server
-rw-r--r-- | servers/gpib_server_lin/src/gpib_conn.cpp | 12 | ||||
-rw-r--r-- | servers/gpib_server_lin/src/scope_functions.cpp | 49 | ||||
-rw-r--r-- | servers/gpib_server_lin/src/scope_functions.h | 1 |
3 files changed, 62 insertions, 0 deletions
diff --git a/servers/gpib_server_lin/src/gpib_conn.cpp b/servers/gpib_server_lin/src/gpib_conn.cpp index df5be78..74d787e 100644 --- a/servers/gpib_server_lin/src/gpib_conn.cpp +++ b/servers/gpib_server_lin/src/gpib_conn.cpp @@ -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; diff --git a/servers/gpib_server_lin/src/scope_functions.cpp b/servers/gpib_server_lin/src/scope_functions.cpp index 5b3e34c..1e7c4ae 100644 --- a/servers/gpib_server_lin/src/scope_functions.cpp +++ b/servers/gpib_server_lin/src/scope_functions.cpp @@ -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); diff --git a/servers/gpib_server_lin/src/scope_functions.h b/servers/gpib_server_lin/src/scope_functions.h index ef33c64..1d8ee43 100644 --- a/servers/gpib_server_lin/src/scope_functions.h +++ b/servers/gpib_server_lin/src/scope_functions.h @@ -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); |