|
|
|
@ -41,6 +41,8 @@ unsigned char scope_raw_screenshot_data[4194304];
|
|
|
|
|
double scope_raw_trace_data[65535];
|
|
|
|
|
double scope_raw_position_data[65535];
|
|
|
|
|
|
|
|
|
|
char scope_segarray[4194304];
|
|
|
|
|
|
|
|
|
|
unsigned long scopeScreenWidth (const char * scopeType) {
|
|
|
|
|
if (strcmp("HP54600OS", scopeType) == 0) {
|
|
|
|
|
return 512;
|
|
|
|
@ -79,7 +81,6 @@ unsigned long scopeScreenSize (const char * scopeType) {
|
|
|
|
|
|
|
|
|
|
int gpib_read_binblock(int ud, int max_num_bytes, const char * scopeType)
|
|
|
|
|
{
|
|
|
|
|
char segarray[4194304];
|
|
|
|
|
long array_pointer;
|
|
|
|
|
long ai;
|
|
|
|
|
|
|
|
|
@ -95,7 +96,7 @@ int gpib_read_binblock(int ud, int max_num_bytes, const char * scopeType)
|
|
|
|
|
ibtmo(ud, T30s);
|
|
|
|
|
ibeos(ud, 0x0);
|
|
|
|
|
|
|
|
|
|
ai = gpib_read_array(ud, max_num_bytes, segarray);
|
|
|
|
|
ai = gpib_read_array(ud, max_num_bytes, scope_segarray);
|
|
|
|
|
if (ai == -1) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
@ -104,14 +105,14 @@ int gpib_read_binblock(int ud, int max_num_bytes, const char * scopeType)
|
|
|
|
|
ai = 0;
|
|
|
|
|
for (x=0;x<scopeScreenWidth(scopeType);x++) {
|
|
|
|
|
for (y=0;y<scopeScreenHeight(scopeType);y++) {
|
|
|
|
|
if ((x & 0x7) == 0) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (segarray[((x >> 3)+(y*(560/8)))+17] & 0x80) << 0;
|
|
|
|
|
if ((x & 0x7) == 1) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (segarray[((x >> 3)+(y*(560/8)))+17] & 0x40) << 1;
|
|
|
|
|
if ((x & 0x7) == 2) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (segarray[((x >> 3)+(y*(560/8)))+17] & 0x20) << 2;
|
|
|
|
|
if ((x & 0x7) == 3) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (segarray[((x >> 3)+(y*(560/8)))+17] & 0x10) << 3;
|
|
|
|
|
if ((x & 0x7) == 4) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (segarray[((x >> 3)+(y*(560/8)))+17] & 0x08) << 4;
|
|
|
|
|
if ((x & 0x7) == 5) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (segarray[((x >> 3)+(y*(560/8)))+17] & 0x04) << 5;
|
|
|
|
|
if ((x & 0x7) == 6) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (segarray[((x >> 3)+(y*(560/8)))+17] & 0x02) << 6;
|
|
|
|
|
if ((x & 0x7) == 7) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (segarray[((x >> 3)+(y*(560/8)))+17] & 0x01) << 7;
|
|
|
|
|
if ((x & 0x7) == 0) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (scope_segarray[((x >> 3)+(y*(560/8)))+17] & 0x80) << 0;
|
|
|
|
|
if ((x & 0x7) == 1) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (scope_segarray[((x >> 3)+(y*(560/8)))+17] & 0x40) << 1;
|
|
|
|
|
if ((x & 0x7) == 2) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (scope_segarray[((x >> 3)+(y*(560/8)))+17] & 0x20) << 2;
|
|
|
|
|
if ((x & 0x7) == 3) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (scope_segarray[((x >> 3)+(y*(560/8)))+17] & 0x10) << 3;
|
|
|
|
|
if ((x & 0x7) == 4) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (scope_segarray[((x >> 3)+(y*(560/8)))+17] & 0x08) << 4;
|
|
|
|
|
if ((x & 0x7) == 5) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (scope_segarray[((x >> 3)+(y*(560/8)))+17] & 0x04) << 5;
|
|
|
|
|
if ((x & 0x7) == 6) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (scope_segarray[((x >> 3)+(y*(560/8)))+17] & 0x02) << 6;
|
|
|
|
|
if ((x & 0x7) == 7) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (scope_segarray[((x >> 3)+(y*(560/8)))+17] & 0x01) << 7;
|
|
|
|
|
if (scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] == 0x0) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = 255;
|
|
|
|
|
if (scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] == 0x80) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = 0;
|
|
|
|
|
}
|
|
|
|
@ -606,8 +607,7 @@ int scope_perform_initial_setup(const char * scopeType, int gpibDevice) {
|
|
|
|
|
|
|
|
|
|
#define ENABLE_PROFILING
|
|
|
|
|
|
|
|
|
|
int scope_get_channel_trace(int desired_channel, const char * scopeType, int gpibDevice) {
|
|
|
|
|
char segarray[4194304];
|
|
|
|
|
long scope_get_channel_trace(int desired_channel, const char * scopeType, int gpibDevice) {
|
|
|
|
|
long array_pointer;
|
|
|
|
|
long ai;
|
|
|
|
|
|
|
|
|
@ -657,7 +657,7 @@ printf("[PROFILE] %f s\n\r", ((tp3.tv_nsec+(tp3.tv_sec*1e9))-(tp2.tv_nsec+(tp2.t
|
|
|
|
|
#ifdef ENABLE_EXTRA_DEBUGGING
|
|
|
|
|
printf("[DEBG] Trying to read %i bytes from GPIB device...\n", 65535);
|
|
|
|
|
#endif
|
|
|
|
|
ai = gpib_read_array(gpibDevice, 65535, segarray);
|
|
|
|
|
ai = gpib_read_array(gpibDevice, 65535, scope_segarray);
|
|
|
|
|
if (ai == -1) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
@ -669,16 +669,16 @@ printf("[PROFILE] %f s\n\r", ((tp3.tv_nsec+(tp3.tv_sec*1e9))-(tp2.tv_nsec+(tp2.t
|
|
|
|
|
clock_gettime(CLOCK_REALTIME, &tp4);
|
|
|
|
|
printf("[PROFILE] %f s\n\r", ((tp4.tv_nsec+(tp4.tv_sec*1e9))-(tp3.tv_nsec+(tp3.tv_sec*1e9)))/1e9);
|
|
|
|
|
#endif
|
|
|
|
|
TQString preamble(segarray);
|
|
|
|
|
TQString preamble(scope_segarray);
|
|
|
|
|
TQStringList resultPairs = TQStringList::split(";", preamble, FALSE);
|
|
|
|
|
// Find/initialize critical data values
|
|
|
|
|
double ymult;
|
|
|
|
|
double yoffset;
|
|
|
|
|
double yposition;
|
|
|
|
|
const char* yunits;
|
|
|
|
|
double xincr;
|
|
|
|
|
double xposition;
|
|
|
|
|
const char* xunits;
|
|
|
|
|
double ymult = 0;
|
|
|
|
|
double yoffset = 0;
|
|
|
|
|
double yposition = 0;
|
|
|
|
|
char* yunits = NULL;
|
|
|
|
|
double xincr = 0;
|
|
|
|
|
double xposition = 0;
|
|
|
|
|
char* xunits = NULL;
|
|
|
|
|
|
|
|
|
|
if (resultPairs.count() > 15) {
|
|
|
|
|
ymult = resultPairs[13].toDouble();
|
|
|
|
@ -690,6 +690,14 @@ printf("[PROFILE] %f s\n\r", ((tp4.tv_nsec+(tp4.tv_sec*1e9))-(tp3.tv_nsec+(tp3.t
|
|
|
|
|
xunits = strdup(resultPairs[8]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If the units are desired, comment out these lines...
|
|
|
|
|
if (yunits) {
|
|
|
|
|
free(yunits);
|
|
|
|
|
}
|
|
|
|
|
if (xunits) {
|
|
|
|
|
free(xunits);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get the curve data now
|
|
|
|
|
sprintf(falpha,"CURVE?");
|
|
|
|
|
#ifdef ENABLE_EXTRA_DEBUGGING
|
|
|
|
@ -703,7 +711,7 @@ printf("[PROFILE] %f s\n\r", ((tp5.tv_nsec+(tp5.tv_sec*1e9))-(tp4.tv_nsec+(tp4.t
|
|
|
|
|
#ifdef ENABLE_EXTRA_DEBUGGING
|
|
|
|
|
printf("[DEBG] Trying to read %i bytes from GPIB device...\n", 65535*2);
|
|
|
|
|
#endif
|
|
|
|
|
ai = gpib_read_array(gpibDevice, 65535*2, segarray);
|
|
|
|
|
ai = gpib_read_array(gpibDevice, 65535*2, scope_segarray);
|
|
|
|
|
if (ai == -1) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
@ -718,10 +726,14 @@ printf("[PROFILE] %f s\n\r", ((tp6.tv_nsec+(tp6.tv_sec*1e9))-(tp5.tv_nsec+(tp5.t
|
|
|
|
|
// Interpret the results
|
|
|
|
|
long pointCount = ai/2;
|
|
|
|
|
double horizPos = 0.0;
|
|
|
|
|
char yheaderlen[2];
|
|
|
|
|
yheaderlen[0] = scope_segarray[1];
|
|
|
|
|
yheaderlen[1] = 0;
|
|
|
|
|
int data_offset = atoi(yheaderlen) + 2;
|
|
|
|
|
for (array_pointer=0; array_pointer<pointCount; array_pointer++) {
|
|
|
|
|
TQ_INT16 tempvalue;
|
|
|
|
|
tempvalue = segarray[(array_pointer*2)+1]; // LSB
|
|
|
|
|
tempvalue = tempvalue | (segarray[(array_pointer*2)+0] << 8); // MSB
|
|
|
|
|
tempvalue = scope_segarray[(array_pointer*2)+1+data_offset]; // LSB
|
|
|
|
|
tempvalue = tempvalue | (scope_segarray[(array_pointer*2)+0+data_offset] << 8); // MSB
|
|
|
|
|
scope_raw_trace_data[array_pointer] = tempvalue;
|
|
|
|
|
scope_raw_trace_data[array_pointer] = (scope_raw_trace_data[array_pointer] * ymult)-yoffset;
|
|
|
|
|
scope_raw_position_data[array_pointer] = horizPos;
|
|
|
|
@ -925,7 +937,6 @@ int scope_get_channel_seconds_div(double * retval, int desired_channel, const ch
|
|
|
|
|
else {
|
|
|
|
|
floatstring[ai]=0;
|
|
|
|
|
*retval = ((atof(floatstring)*xincr)/scope_get_number_of_vertical_divisions(scopeType, gpibDevice));
|
|
|
|
|
printf("[RAJA DEBUG 650.0] nr_p: %f, xincr: %E, vert_divs: %d, s/div: %f\n\r", atof(floatstring), xincr, scope_get_number_of_vertical_divisions(scopeType, gpibDevice), *retval); fflush(stdout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef ENABLE_EXTRA_DEBUGGING
|
|
|
|
|