Repository navigation
Expand file tree
/
Copy pathr4stest.cpp
More file actions
113 lines (87 loc) · 2.22 KB
/
Copy pathr4stest.cpp
File metadata and controls
113 lines (87 loc) · 2.22 KB
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
/* -------------------------------------------------------------
*
* file: r4stest.cpp
*
* description: main program for ROC4sens test
*
* author: Beat Meier
* modified: 24.7.2017
*
* -------------------------------------------------------------
*/
#include <string>
#include <vector>
#include "r4stest.h"
#include "profiler.h"
using namespace std;
// --- globals ---------------------------------------
int nEntry; // counts the chip tests
CTestboard tb;
CSettings settings; // global settings
CProtocol Log;
CRoc roc;
void help()
{
printf( "usage: r4stest 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("r4stest.ini") ) {
printf("error reading \"r4stest.ini\"\n");
return 2;
}
// --- open log file ----------------------------------
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" );
}
Log.flush();
// --- call command interpreter -----------------------
nEntry = 0;
printf( "r4stest main calls cmd\n" );
cmd();
tb.Close();
}
catch( CRpcError &e ) {
e.What();
}
return 0;
}