File: ibError.c

package info (click to toggle)
linux-gpib-user 4.3.7-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,760 kB
  • sloc: ansic: 10,381; perl: 1,120; xml: 375; makefile: 335; yacc: 335; tcl: 308; python: 173; php: 157; lex: 144; sh: 134; lisp: 94
file content (174 lines) | stat: -rw-r--r-- 4,389 bytes parent folder | download | duplicates (2)
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/***************************************************************************
                          lib/ibError.c
                             -------------------

    copyright            : (C) 2001,2002,2003 by Frank Mori Hess
    email                : fmhess@users.sourceforge.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "ib_internal.h"

#include <time.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>

char *routptr[]= {
    "ibrd",
    "ibwrt",
    "ibcmd",
    "ibwait",
    "ibrpp",
    "ibonl",
    "ibsic",
    "ibsre",
    "ibgts",
    "ibcac",
    "ibpoke",
    "iblines",
    "ibpad",
    "ibsad",
    "ibtmo",
    "ibeot",
    "ibeos",
    "ibrsv",  /*17*/

    "dvtrg",
    "dvclr",
    "dvrsp",
    "dvrd",
    "dvwrt", /*22*/

    "cfcbase",
    "cfcirq",
    "cfcdma", /*25*/

    "unknown"
  };

char *ibVerbCode(int code)
{

  if (code >=0 && code <=17)
	  return routptr[code];
  else if (code >=100 && code <=104)
	  return routptr[18+(code-100)];
  else if (code >=200 && code <=202)
	  return routptr[23+(code-200)];
  else
	  return routptr[26];
}

void ibPutMsg (char *format,...)
{

va_list ap;

  time_t tm;
  char strtime[60];


    va_start(ap,format);
    time(&tm);
    strftime(strtime,59,"%c",gmtime(&tm));

    fprintf(stderr,"\n gpib-message   :[%s] ",strtime);
    vfprintf(stderr, format, ap);
    va_end(ap);

}

void ibPutErrlog(int ud,char *routine)
{

time_t tm;
char strtime[60];

    if (ibsta & ERR) {
    time(&tm);
    strftime(strtime,59,"%c",gmtime(&tm));

    if (ud>=0)
	    fprintf(stderr, "\n %-15s:[%s](%s)< ",routine,strtime, ibConfigs[ud]->name);
    else
	    fprintf(stderr, "\n %-15s:[%s](-)< " ,routine,strtime);

    if (ibsta & ERR)
	    fprintf(stderr," ERR");
    if (ibsta & TIMO)
	    fprintf(stderr," TIMO");
    if (ibsta & END)
	    fprintf(stderr," END");
    if (ibsta & SRQI)
	    fprintf(stderr," SRQI");
    /*if (ibsta & RQS)  fprintf(stderr," RQS");*/
    if (ibsta & CMPL)
	    fprintf(stderr," CMPL");
    /*if (ibsta & LOK)  fprintf(stderr," LOK");*/
    /*if (ibsta & REM)  fprintf(stderr," REM");*/
    if (ibsta & CIC)
	    fprintf(stderr," CIC");
    if (ibsta & ATN)
	    fprintf(stderr," ATN");
    if (ibsta & TACS)
	    fprintf(stderr," TACS");
    if (ibsta & LACS)
	    fprintf(stderr," LACS");
    /*if (ibsta & DTAS) fprintf(stderr," DATS");*/
    /*if (ibsta & DCAS) fprintf(stderr," DCTS");*/

    fprintf(stderr,"> ");

    if (iberr == EDVR)
	    fprintf(stderr," EDVR <OS Error>\n");
    if (iberr == ECIC)
	    fprintf(stderr," ECIC <Not CIC>\n");
    if (iberr == ENOL)
	    fprintf(stderr," ENOL <No Listener>\n");
    if (iberr == EADR)
	    fprintf(stderr," EADR <Adress Error>\n");
    if (iberr == EARG)
	    fprintf(stderr," ECIC <Invalid Argument>\n");
    if (iberr == ESAC)
	    fprintf(stderr," ESAC <No Sys Ctrlr>\n");
    if (iberr == EABO)
	    fprintf(stderr," EABO <Operation Aborted>\n");
    if (iberr == ENEB)
	    fprintf(stderr," ENEB <No Gpib Board>\n");
    if (iberr == EOIP)
	    fprintf(stderr," EOIP <Async I/O in prg>\n");
    if (iberr == ECAP)
	    fprintf(stderr," ECAP <No Capability>\n");
    if (iberr == EFSO)
	    fprintf(stderr," EFSO <File sys. error>\n");
    if (iberr == EBUS)
	    fprintf(stderr," EBUS <Command error>\n");
    if (iberr == ESTB)
	    fprintf(stderr," ESTB <Status byte lost>\n");
    if (iberr == ESRQ)
	    fprintf(stderr," ESRQ <SRQ stuck on>\n");
    if (iberr == ECNF)
	    fprintf(stderr," ECNF <Configuration file error>\n");
    if (iberr == ETAB)
	    fprintf(stderr," ETAB <Device Table Overflow>\n");

    if (iberr == EDVR && ibcnt != 0) {
      fprintf(stderr,"               -- errno=%d (%s)\n",ibcnt,strerror(ibcnt));
    }
  }
}