diff options
| author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-18 16:56:50 -0500 |
|---|---|---|
| committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-18 16:56:50 -0500 |
| commit | 592594bb7c774f8fb97a4c39c9041da31226fb62 (patch) | |
| tree | 617480f251bece8cf291d045bb2dcb37c6f4dce1 /servers/gpib_server_lin/src/scope_functions.cpp | |
| parent | 23eadbf9246280ce6473a4fe4d3605cd730eb8c8 (diff) | |
| download | ulab-592594bb7c774f8fb97a4c39c9041da31226fb62.tar.gz ulab-592594bb7c774f8fb97a4c39c9041da31226fb62.zip | |
Add run controls to scope
Diffstat (limited to 'servers/gpib_server_lin/src/scope_functions.cpp')
| -rw-r--r-- | servers/gpib_server_lin/src/scope_functions.cpp | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/servers/gpib_server_lin/src/scope_functions.cpp b/servers/gpib_server_lin/src/scope_functions.cpp index 0ba0bc1..3385a1e 100644 --- a/servers/gpib_server_lin/src/scope_functions.cpp +++ b/servers/gpib_server_lin/src/scope_functions.cpp @@ -350,6 +350,55 @@ int scope_set_acquisition(int status,const char * scopeType, int gpibDevice) { } } +int scope_get_acquisition(int * 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 run state\n\r"); + sprintf(falpha,"ACQUIRE:STATE?"); + #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 = atoi(floatstring); + } + + #ifdef ENABLE_EXTRA_DEBUGGING + printf("[DEBG] Read %li bytes from GPIB device\n", ai); + #endif + + return 0; + } + else { + return -1; + } +} + int scope_set_channel_state(int desired_channel, int status,const char * scopeType, int gpibDevice) { if ((strcmp("HP54600OS", scopeType) == 0) || (strcmp("TDS744AOS", scopeType) == 0)) { printf("[INFO] Setting channel %d state to %i\n\r", desired_channel, status); @@ -387,7 +436,7 @@ int scope_set_channel_state(int desired_channel, int status,const char * scopeTy printf("[DEBG] Writing: %s\n\r", falpha); #endif if (gpib_write(gpibDevice, falpha) == 0) { - usleep(2*1000000); // The scope is slow to respond, and also blind to commands during the update window! [RAJA TESTME] + usleep(2*1000000); // The scope is slow to respond, and also blind to commands during the update window! This makes sure that the scope will actually process subsequent commands return 0; } else { |
