forked from frmeier/psi46test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
psi46test.cpp
132 lines (109 loc) · 2.76 KB
/
psi46test.cpp
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
/* -------------------------------------------------------------
*
* file: psi46test.cpp
*
* description: main program for PSI46V2 Wafer tester
*
* author: Beat Meier
* modified: 6.2.2006
*
* rev:
*
* -------------------------------------------------------------
*/
#include <string>
#include <vector>
#include "psi46test.h"
#include "profiler.h"
using namespace std;
// --- globals ---------------------------------------
int nEntry; // counts the chip tests
CTestboard tb;
CSettings settings; // global settings
CProber prober;
CProtocol Log;
void help()
{
printf("psi46test <log file name>\n");
}
char filename[512];
int main(int argc, char* argv[])
{
string usbId;
printf(VERSIONINFO "\n");
if (argc != 2) { help(); return 1; }
strncpy(filename, argv[1], sizeof(filename));
// --- load settings ----------------------------------
if (!settings.read("psi46test.ini"))
{
printf("error reading \"psi46test.ini\"\n");
return 2;
}
// --- open log file ----------------------------------
/* FILE *f = fopen(filename,"rb");
if (f)
{
printf("Log file \"%s\" exist!\n", filename);
fclose(f);
return 1;
} */
if (!Log.open(filename))
{
printf("log: error creating file\n");
return 3;
}
// --- open test board --------------------------------
Log.section("DTB");
try
{
if (!tb.FindDTB(usbId)) {}
else if (tb.Open(usbId))
{
printf("\nDTB %s opened\n", usbId.c_str());
string info;
try
{
tb.GetInfo(info);
printf("--- DTB info-------------------------------------\n"
"%s"
"-------------------------------------------------\n", info.c_str());
Log.puts(info.c_str());
tb.Welcome();
tb.Flush();
}
catch(CRpcError &e)
{
e.What();
printf("ERROR: DTB software version could not be identified, please update it!\n");
tb.Close();
printf("Connection to Board %s has been cancelled\n", usbId.c_str());
}
}
else
{
printf("USB error: %s\n", tb.ConnectionError());
printf("ATB: could not open port to device %s\n", settings.port_tb);
printf("Connect testboard and try command 'scan' to find connected devices.\n");
printf("Make sure you have permission to access USB devices.\n");
}
// --- open prober ------------------------------------
if (settings.port_prober>=0)
if (!prober.open(settings.port_prober))
{
printf("Prober: could not open port %i\n",
settings.port_prober);
Log.puts("Prober: could not open port\n");
return 4;
}
Log.flush();
// --- call command interpreter -----------------------
nEntry = 0;
cmd();
tb.Close();
}
catch (CRpcError &e)
{
e.What();
}
return 0;
}