-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathregDevLsiLso.c
143 lines (123 loc) · 3.91 KB
/
regDevLsiLso.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
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
#include <string.h>
#include <stdlib.h>
#include <dbAccess.h>
#include <dbEvent.h>
#include <epicsString.h>
#include "regDevSup.h"
/* lsi **************************************************************/
#include <lsiRecord.h>
long regDevInitRecordLsi(lsiRecord *);
long regDevReadLsi(lsiRecord *);
struct devsup regDevLsi =
{
5,
NULL,
NULL,
regDevInitRecordLsi,
regDevGetInIntInfo,
regDevReadLsi
};
epicsExportAddress(dset, regDevLsi);
long regDevInitRecordLsi(lsiRecord* record)
{
regDevPrivate* priv;
int status;
priv = regDevAllocPriv((dbCommon*)record);
if (!priv) return S_dev_noMemory;
priv->dtype = epicsStringT;
priv->L = record->sizv;
status = regDevIoParse((dbCommon*)record, &record->inp, TYPE_STRING);
if (status) return status;
status = regDevAssertType((dbCommon*)record, TYPE_STRING);
if (status) return status;
priv->data.buffer = record->val;
return status;
}
long regDevReadLsi(lsiRecord* record)
{
char* end;
int status;
status = regDevReadArray((dbCommon*)record, record->sizv);
if (status == ASYNC_COMPLETION) return S_dev_success;
if (status) return status;
/* we cannot assume that the string was terminated */
end = memchr(record->val, 0, record->sizv);
if (end) record->len = (epicsUInt32)(end - record->val);
else record->val[record->len = record->sizv-1] = 0;
return S_dev_success;
}
/* lso **************************************************************/
#include <lsoRecord.h>
long regDevInitRecordLso(lsoRecord *);
long regDevWriteLso(lsoRecord *);
long regDevUpdateLso(lsoRecord *);
struct devsup regDevLso =
{
5,
NULL,
NULL,
regDevInitRecordLso,
regDevGetInIntInfo,
regDevWriteLso
};
epicsExportAddress(dset, regDevLso);
long regDevInitRecordLso(lsoRecord* record)
{
regDevPrivate* priv;
char* end;
int status;
priv = regDevAllocPriv((dbCommon*)record);
if (!priv) return S_dev_noMemory;
priv->dtype = epicsStringT;
priv->L = record->sizv;
status = regDevIoParse((dbCommon*)record, &record->out, TYPE_STRING);
if (status) return status;
status = regDevAssertType((dbCommon*)record, TYPE_STRING);
if (status) return status;
priv->data.buffer = record->val;
status = regDevInstallUpdateFunction((dbCommon*)record, regDevUpdateLso);
if (status) return status;
if (priv->rboffset == DONT_INIT) return S_dev_success;
status = regDevReadArray((dbCommon*)record, record->sizv);
if (status) return status;
end = memchr(record->val, 0, record->sizv);
if (end) record->len = (epicsUInt32)(end - record->val);
else record->val[record->len = record->sizv-1] = 0;
return S_dev_success;
}
long regDevUpdateLso(lsoRecord* record)
{
char* end;
int status;
unsigned short monitor_mask;
status = regDevReadArray((dbCommon*)record, record->sizv);
if (status == ASYNC_COMPLETION) return S_dev_success;
end = memchr(record->val, 0, record->sizv);
if (end) record->len = (epicsUInt32)(end - record->val);
else record->val[record->len = record->sizv-1] = 0;
monitor_mask = recGblResetAlarms(record);
if (record->len != record->olen ||
memcmp(record->oval, record->val, record->len))
{
monitor_mask |= DBE_VALUE | DBE_LOG;
memcpy(record->oval, record->val, record->len);
}
if (record->len != record->olen)
{
record->olen = record->len;
db_post_events(record, &record->len, DBE_VALUE | DBE_LOG);
}
if (monitor_mask)
db_post_events(record, record->val, monitor_mask);
return status;
}
long regDevWriteLso(lsoRecord* record)
{
int status;
regDevCheckAsyncWriteResult(record);
if (record->len+1 < record->sizv)
memset(record->val+record->len+1, 0, record->sizv-record->len-1);
status = regDevWriteArray((dbCommon*) record, record->sizv);
if (status == ASYNC_COMPLETION) return S_dev_success;
return status;
}