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.cpp105
1 files changed, 105 insertions, 0 deletions
diff --git a/servers/gpib_server_lin/src/scope_functions.cpp b/servers/gpib_server_lin/src/scope_functions.cpp
index 68f2274..ce5adcd 100644
--- a/servers/gpib_server_lin/src/scope_functions.cpp
+++ b/servers/gpib_server_lin/src/scope_functions.cpp
@@ -486,6 +486,62 @@ int scope_set_trigger_channel(int desired_channel,const char * scopeType, int gp
}
}
+int scope_get_trigger_channel(int * retval, const char * scopeType, int gpibDevice) {
+ char floatstring[1024];
+ long ai;
+ int max_num_bytes = 0;
+
+ printf("[INFO] Getting trigger channel\n\r");
+ if (strcmp("HP54600OS", scopeType) == 0) {
+ // FIXME
+ // Not supported (yet)
+ return -1;
+ }
+ else if (strcmp("TDS744AOS", scopeType) == 0) {
+ sprintf(falpha, "TRIGGER:MAIN:EDGE:SOURCE?");
+ #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;
+ TQString retchan(floatstring);
+ if (retchan.startsWith("CH1")) *retval = 1;
+ else if (retchan.startsWith("CH2")) *retval = 2;
+ else if (retchan.startsWith("CH3")) *retval = 3;
+ else if (retchan.startsWith("CH4")) *retval = 4;
+ else {
+ *retval = -1;
+ return -1;
+ }
+ }
+
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Read %li bytes from GPIB device\n", ai);
+ #endif
+
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
int scope_set_trigger_level(float desired_level,const char * scopeType, int gpibDevice) {
if ((strcmp("HP54600OS", scopeType) == 0) || (strcmp("TDS744AOS", scopeType) == 0)) {
printf("[INFO] Setting scope trigger level to %f\n\r", desired_level);
@@ -522,6 +578,55 @@ int scope_set_trigger_level(float desired_level,const char * scopeType, int gpib
}
}
+int scope_get_trigger_level(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 trigger level\n\r");
+ sprintf(falpha,"TRIGGER:MAIN:LEVEL?");
+ #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);
+ }
+
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Read %li bytes from GPIB device\n", ai);
+ #endif
+
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
int scope_set_channel_position(int desired_channel, float desired_level,const char * scopeType, int gpibDevice) {
if ((strcmp("HP54600OS", scopeType) == 0) || (strcmp("TDS744AOS", scopeType) == 0)) {
printf("[INFO] Setting scope channel %d level to %f\n\r", desired_channel, desired_level);