equal
deleted
inserted
replaced
|
1 /* |
|
2 * Stringin device support for EPICS time stamps |
|
3 * |
|
4 * devTimestampSI.c,v 1.1.2.1 2004/01/08 21:08:56 norume Exp |
|
5 * |
|
6 * fixed for vxWorks 5.4.2 bfr |
|
7 */ |
|
8 |
|
9 #include <string.h> |
|
10 #include <epicsStdio.h> |
|
11 #include <epicsTime.h> |
|
12 #include <stringinRecord.h> |
|
13 #include <alarm.h> |
|
14 #include <devSup.h> |
|
15 #include <recGbl.h> |
|
16 #include <epicsExport.h> |
|
17 |
|
18 static long |
|
19 read_stringin (struct stringinRecord *psi) |
|
20 { |
|
21 int l; |
|
22 |
|
23 recGblGetTimeStamp(psi); |
|
24 if (strcmp(psi->inp.value.instio.string,"%s")==0) { |
|
25 l = epicsSnprintf(psi->val, sizeof psi->val, "%u", psi->time.secPastEpoch); |
|
26 } else { |
|
27 l = epicsTimeToStrftime(psi->val, sizeof psi->val, psi->inp.value.instio.string, &psi->time); |
|
28 } |
|
29 if (l >= sizeof psi->val) { |
|
30 psi->udf = 1; |
|
31 recGblSetSevr(psi,UDF_ALARM,INVALID_ALARM); |
|
32 return -1; |
|
33 } |
|
34 psi->udf = 0; |
|
35 return 0; |
|
36 } |
|
37 |
|
38 struct { |
|
39 long number; |
|
40 DEVSUPFUN dev_report; |
|
41 DEVSUPFUN init; |
|
42 DEVSUPFUN init_record; /*returns: (0,2)=>(success,success no convert)*/ |
|
43 DEVSUPFUN get_ioint_info; |
|
44 DEVSUPFUN read_stringin;/*(0)=>(success ) */ |
|
45 } devSiTimestampWorkaround = { |
|
46 6, |
|
47 NULL, |
|
48 NULL, |
|
49 NULL, |
|
50 NULL, |
|
51 read_stringin |
|
52 }; |
|
53 epicsExportAddress(dset,devSiTimestampWorkaround); |