-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patht1.c
104 lines (79 loc) · 1.71 KB
/
t1.c
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
/*
#include "Python.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <assert.h>
#include "tpi_c.h"
#include "adiUserI.h"
#include "ci_types.h"
#include "libcicpi.h"
#define BUF_LEN 65536
char buf1[ BUF_LEN ];
char buf2[ BUF_LEN ];
INT32 fw_ret;
#include "t1.h"
// A simple interface to firmware commands that don't return any crazy
// huge binary strings or anything:
//
// returns pointer to answer on success ( buf2 )
// returns 0 on failure
// places return code in global fw_ret
//
//
// WARNING: Will die horribly if buffers overflow.
//
/*
char* fw(char* cmd) {
INT32 cmd_len,ans_len;
//TODO: dynamic reallocation in case of buffer too small
// or split a large command into many small ones.
assert( strlen(cmd) < BUF_LEN );
strcpy(buf1,cmd);
cmd_len = strlen(buf1);
strcpy((buf1+cmd_len),"\n");
cmd_len++;
ans_len = BUF_LEN-1;
HpFwTask(buf1, &cmd_len, buf2, &ans_len, &fw_ret);
buf2[ans_len]=0;
return buf2;
}
// Returns 1 on pass, 0 on fail, -1 on error
int ftst() {
char* r;
r = fw("FTST?");
if( !r ) {
printf("ftst() error number %d\n",(int)fw_ret);
return -1;
}
if(*(r+5) == 'P') {
return 1;
}
return 0;
}
void atexit_cleanup(void) {
HpTerm();
printf("HpTerm() -- byebye 93k\n");
}
int dErr;
char dErrMsg[ BUF_LEN ];
void throw_error(char* s) {
dErr = 1;
strcpy(dErrMsg,s);
printf("Throwing error: %s\n",dErrMsg);
}
char* dTsName() {
int status;
status = GetTestsuiteName( buf1 );
if( status != 0 ) {
throw_error("Internal error in GetTestsuiteName");
strcpy( buf1, "NoNameLoaded" );
}
return buf1;
}
int test_throw_error() {
throw_error("test_throw_error succeeded.");
return 1;
}
*/