summaryrefslogtreecommitdiffstats
path: root/servers/gpib_server_lin/src/gpib_conn.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'servers/gpib_server_lin/src/gpib_conn.cpp')
-rw-r--r--servers/gpib_server_lin/src/gpib_conn.cpp136
1 files changed, 127 insertions, 9 deletions
diff --git a/servers/gpib_server_lin/src/gpib_conn.cpp b/servers/gpib_server_lin/src/gpib_conn.cpp
index c0d43ca..6837725 100644
--- a/servers/gpib_server_lin/src/gpib_conn.cpp
+++ b/servers/gpib_server_lin/src/gpib_conn.cpp
@@ -263,7 +263,17 @@ void GPIBSocket::commandLoop() {
if (m_instrumentCommand != "") {
if (m_activeDeviceType == 2) {
// Oscilloscope
- if (m_instrumentCommand == "SETHORIZTIMEBASE") { // Want to change horizontal timebase
+ if (m_instrumentCommand == "RESET") { // Want to reset scope
+ if (scope_reset(m_serverParent->m_funcgenType.ascii(), m_serverParent->m_funcgenDeviceSocket) == 0) {
+ ds << TQString("ACK");
+ writeEndOfFrame();
+ }
+ else {
+ ds << TQString("NCK");;
+ writeEndOfFrame();
+ }
+ }
+ else if (m_instrumentCommand == "SETHORIZTIMEBASE") { // Want to change horizontal timebase
double value;
ds >> value;
if (scope_set_timebase(value, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket) == 0) {
@@ -282,13 +292,17 @@ void GPIBSocket::commandLoop() {
traceLength = scope_get_channel_trace(value, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket);
if (traceLength > 0) {
int i;
- TQFloatArray traceData;
+ TQDoubleArray traceData;
+ TQDoubleArray positionData;
traceData.resize(traceLength);
+ positionData.resize(traceLength);
for (i=0; i<traceLength; i++) {
traceData[i] = scope_raw_trace_data[i];
+ positionData[i] = scope_raw_position_data[i];
}
ds << TQString("ACK");
ds << traceData;
+ ds << positionData;
writeEndOfFrame();
}
else {
@@ -310,6 +324,49 @@ void GPIBSocket::commandLoop() {
writeEndOfFrame();
}
}
+ else if (m_instrumentCommand == "GETVOLTSDIV") { // Want to get volts per division
+ double voltsdiv;
+ TQ_INT32 value;
+ ds >> value;
+ if (scope_get_channel_volts_div(&voltsdiv, value, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket) == 0) {
+ ds << TQString("ACK");
+ ds << voltsdiv;
+ writeEndOfFrame();
+ }
+ else {
+ ds << TQString("NCK");
+ writeEndOfFrame();
+ }
+ }
+ else if (m_instrumentCommand == "GETSECONDSSDIV") { // Want to get seconds per division
+ double secondsdiv;
+ TQ_INT32 value;
+ ds >> value;
+ if (scope_get_channel_seconds_div(&secondsdiv, value, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket) == 0) {
+ ds << TQString("ACK");
+ ds << secondsdiv;
+ writeEndOfFrame();
+ }
+ else {
+ ds << TQString("NCK");
+ writeEndOfFrame();
+ }
+ }
+ else if (m_instrumentCommand == "GETTRACESAMPLECOUNT") { // Want to get number of samples in the trace
+ unsigned long samples;
+ TQ_INT32 value;
+ ds >> value;
+ if (scope_get_channel_sample_count(&samples, value, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket) == 0) {
+ ds << TQString("ACK");
+ TQ_INT32 safeSamples = samples;
+ ds << safeSamples;
+ writeEndOfFrame();
+ }
+ else {
+ ds << TQString("NCK");
+ writeEndOfFrame();
+ }
+ }
else if (m_instrumentCommand == "SETRUNNING") { // Want to change run status
TQ_INT32 value;
ds >> value;
@@ -325,7 +382,7 @@ void GPIBSocket::commandLoop() {
else if (m_instrumentCommand == "SETCHANNELACTIVE") { // Want to change channel enable
TQ_INT32 value1;
ds >> value1;
- TQ_INT32 value2;
+ TQ_INT16 value2;
ds >> value2;
if (scope_set_channel_state(value1, value2, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket) == 0) {
ds << TQString("ACK");
@@ -374,6 +431,60 @@ void GPIBSocket::commandLoop() {
writeEndOfFrame();
}
}
+ else if (m_instrumentCommand == "GETHORIZONTALDIVCOUNT") { // Want the number of horizontal divisions available
+ TQ_INT16 divisions = scope_get_number_of_vertical_divisions(m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket);
+ if (divisions >= 0) {
+ ds << TQString("ACK");
+ ds << divisions;
+ writeEndOfFrame();
+ }
+ else {
+ ds << TQString("NCK");
+ writeEndOfFrame();
+ }
+ }
+ else if (m_instrumentCommand == "GETVERTICALDIVCOUNT") { // Want the number of vertical divisions available
+ TQ_INT16 divisions = scope_get_number_of_horizontal_divisions(m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket);
+ if (divisions >= 0) {
+ ds << TQString("ACK");
+ ds << divisions;
+ writeEndOfFrame();
+ }
+ else {
+ ds << TQString("NCK");
+ writeEndOfFrame();
+ }
+ }
+ else if (m_instrumentCommand == "GETNUMBEROFCHANNELS") { // Want the number of channels available
+ TQ_INT16 divisions = scope_get_number_of_channels(m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket);
+ if (divisions >= 0) {
+ ds << TQString("ACK");
+ ds << divisions;
+ writeEndOfFrame();
+ }
+ else {
+ ds << TQString("NCK");
+ writeEndOfFrame();
+ }
+ }
+ else if (m_instrumentCommand == "GETCHANNELACTIVE") { // Want to get channel activity
+ int state;
+ TQ_INT32 value;
+ ds >> value;
+ if (scope_get_channel_state(&state, value, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket) == 0) {
+ TQ_INT16 safeState = state;
+ ds << TQString("ACK");
+ ds << safeState;
+ writeEndOfFrame();
+ }
+ else {
+ ds << TQString("NCK");
+ writeEndOfFrame();
+ }
+ }
+ else {
+ printf("[WARNING] Received unknown command %s from host %s\n\r", m_instrumentCommand.ascii(), m_remoteHost.ascii()); fflush(stdout);
+ }
}
else if (m_activeDeviceType == 3) {
// Function generator
@@ -476,6 +587,9 @@ void GPIBSocket::commandLoop() {
writeEndOfFrame();
}
}
+ else {
+ printf("[WARNING] Received unknown command %s from host %s\n\r", m_instrumentCommand.ascii(), m_remoteHost.ascii()); fflush(stdout);
+ }
}
else if (m_activeDeviceType == 4) {
// Communications analyzer
@@ -714,8 +828,8 @@ void GPIBSocket::commandLoop() {
writeEndOfFrame();
}
}
- else if (m_instrumentCommand == "GETVERTICALDIVCOUNT") { // Want the number of vertical divisions available
- TQ_INT16 divisions = commanalyzer_get_spectrum_analyzer_number_of_vertical_divisions(m_serverParent->m_commanalyzerType.ascii(), m_serverParent->m_commanalyzerDeviceSocket);
+ else if (m_instrumentCommand == "GETHORIZONTALDIVCOUNT") { // Want the number of horizontal divisions available
+ TQ_INT16 divisions = commanalyzer_get_spectrum_analyzer_number_of_horizontal_divisions(m_serverParent->m_commanalyzerType.ascii(), m_serverParent->m_commanalyzerDeviceSocket);
if (divisions >= 0) {
ds << TQString("ACK");
ds << divisions;
@@ -726,8 +840,8 @@ void GPIBSocket::commandLoop() {
writeEndOfFrame();
}
}
- else if (m_instrumentCommand == "GETTRACESAMPLECOUNT") { // Want the number of samples in a trace
- TQ_INT16 divisions = commanalyzerTraceLength(m_serverParent->m_commanalyzerType.ascii());
+ else if (m_instrumentCommand == "GETVERTICALDIVCOUNT") { // Want the number of vertical divisions available
+ TQ_INT16 divisions = commanalyzer_get_spectrum_analyzer_number_of_vertical_divisions(m_serverParent->m_commanalyzerType.ascii(), m_serverParent->m_commanalyzerDeviceSocket);
if (divisions >= 0) {
ds << TQString("ACK");
ds << divisions;
@@ -738,8 +852,8 @@ void GPIBSocket::commandLoop() {
writeEndOfFrame();
}
}
- else if (m_instrumentCommand == "GETHORIZONTALDIVCOUNT") { // Want the number of horizontal divisions available
- TQ_INT16 divisions = commanalyzer_get_spectrum_analyzer_number_of_horizontal_divisions(m_serverParent->m_commanalyzerType.ascii(), m_serverParent->m_commanalyzerDeviceSocket);
+ else if (m_instrumentCommand == "GETTRACESAMPLECOUNT") { // Want the number of samples in a trace
+ TQ_INT16 divisions = commanalyzerTraceLength(m_serverParent->m_commanalyzerType.ascii());
if (divisions >= 0) {
ds << TQString("ACK");
ds << divisions;
@@ -798,6 +912,9 @@ void GPIBSocket::commandLoop() {
writeEndOfFrame();
}
}
+ else {
+ printf("[WARNING] Received unknown command %s from host %s\n\r", m_instrumentCommand.ascii(), m_remoteHost.ascii()); fflush(stdout);
+ }
}
else {
// Unknown
@@ -970,6 +1087,7 @@ int GPIBServer::readConfig() {
printf("[INFO] %s\n\r", timebuffer);
if (gpib_write(m_scopeDeviceSocket, timebuffer) == 0) {
gpib_write(m_scopeDeviceSocket, datebuffer);
+ scope_perform_initial_setup(m_scopeType.ascii(), m_scopeDeviceSocket);
printf("[INFO] Communication verified\n\r");
}
else {