forked from psi46/psi46test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpsi46test.cpp
154 lines (126 loc) · 3.22 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/* -------------------------------------------------------------
*
* 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;
CWaferList waferList;
void help()
{
printf("psi46test <log file name>\n");
}
string filename;
int main(int argc, char* argv[])
{
string usbId;
printf(VERSIONINFO "\n");
if (argc != 2) { help(); return 1; }
filename = argv[1];
// --- 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 (settings.IsWaferList())
{ // wafer test mode with wafer list
if (!waferList.Read(settings.waferList))
{
printf("No waferlist \"%s\" found!\n", settings.waferList.c_str());
return 5;
}
switch (waferList.SelectWafer(filename))
{
case 1: printf("Wafer %s not in wafer list!\n", filename.c_str());
return 5;
case 2: printf("Wafer %s already tested!\n", filename.c_str());
return 5;
}
filename = filename + ".log";
}
if (!Log.open(filename.c_str()))
{
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("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.proberPort>=0)
if (!prober.Open(settings.proberPort))
{
printf("Prober: could not open port %i\n",
settings.proberPort);
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();
}
if (settings.IsWaferList()) waferList.Write(settings.waferList);
return 0;
}