1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
/*
* Remote Laboratory Instrumentation Server
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (c) 2009 Timothy Pearson
* Raptor Engineering
* http://www.raptorengineeringinc.com
*/
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <getopt.h>
#include "gpib/ib.h"
char falpha[1024];
const char * scopeLongDescription (const char * scopeType) {
if (strcmp("HP54600OS", scopeType) == 0) {
return "Hewlett Packard 54600 series";
}
else if (strcmp("TDS744AOS", scopeType) == 0) {
return "Tektronix 744A series";
}
else if (strcmp("TDS744COS", scopeType) == 0) {
return "Tektronix 744C series";
}
else {
return "UNKNOWN";
}
}
const char * commanalyzerLongDescription (const char * commanalyzerType) {
if (strcmp("HP8924C", commanalyzerType) == 0) {
return "Hewlett Packard 8924 series";
}
else {
return "UNKNOWN";
}
}
const char * companalyzerLongDescription (const char * companalyzerType) {
if (strcmp("HP4191A", companalyzerType) == 0) {
return "Hewlett Packard HP4191 series";
}
else {
return "UNKNOWN";
}
}
const char * funcgenLongDescription (const char * funcgenType) {
if (strcmp("AG33250A", funcgenType) == 0) {
return "Agilent AG33250A";
}
else {
return "UNKNOWN";
}
}
/* returns a device descriptor after prompting user for primary address */
int open_gpib_device(int minor, int pad) {
int ud;
const int sad = 0;
const int send_eoi = 1;
const int eos_mode = 0;
const int timeout = T1s;
printf("[INFO] Trying to open GPIB device %i on board /dev/gpib%i...\n\r", pad, minor);
ud = ibdev(minor, pad, sad, timeout, send_eoi, eos_mode);
if(ud < 0)
{
printf("[WARN] GPIB interface error\n\r");
return -1;
}
return ud;
}
int gpib_write(int ud, const char * buffer) {
if( ibwrt(ud, buffer, strlen(buffer)) & ERR )
{
return -1;
}
return 0;
}
int gpib_read_array(int ud, int max_num_bytes, char * segarray) {
int br;
ibrd(ud, segarray, max_num_bytes-1);
br = ThreadIbcntl();
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Number of bytes read from GPIB device: %li\n", br);
#endif
if ((ThreadIbsta() & ERR) && (br == 0)) {
return -1;
}
return br;
}
int gpib_read_binary(int ud, int max_num_bytes) {
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Trying to read %i bytes from GPIB device...\n", max_num_bytes);
#endif
//ibrd(ud, scope_raw_screenshot_data, max_num_bytes-1);
system("rm -f /tmp/current_scope_screenshot.bmp");
ibrdf(ud, "/tmp/current_scope_screenshot.bmp");
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Number of bytes read from GPIB device: %li\n", ThreadIbcntl());
#endif
if (ThreadIbsta() & ERR) {
return -1;
}
return 0;
}
|