summaryrefslogtreecommitdiffstats
path: root/servers/gpib_server_lin/src/scope_functions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'servers/gpib_server_lin/src/scope_functions.cpp')
-rw-r--r--servers/gpib_server_lin/src/scope_functions.cpp51
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 {