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 /servers/gpib_server_lin/src/scope_functions.cpp | |
parent | 260c25ebe511f9a3ee6454c4e897947fc8eef1f0 (diff) | |
download | ulab-31f91d555b16487cc1670cbfa8c18b2f14993d57.tar.gz ulab-31f91d555b16487cc1670cbfa8c18b2f14993d57.zip |
Add GETHORIZTIMEBASE to gpib server
Diffstat (limited to 'servers/gpib_server_lin/src/scope_functions.cpp')
-rw-r--r-- | servers/gpib_server_lin/src/scope_functions.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
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); |