1tsalarm_get(3EXT) Extended Library Functions tsalarm_get(3EXT)
2
3
4
6 tsalarm_get, tsalarm_set - get or set alarm relays
7
9 cc [ flag... ] file... -ltsalarm [ library... ]
10 #include <tsalarm.h>
11
12 int tsalarm_get(uint32_t alarm_type, uint32_t *alarm_state);
13
14
15 int tsalarm_set(uint32_t alarm_type, uint32_t alarm_state);
16
17
19 alarm_type
20
21 The alarm type whose state is retrieved or set. Valid settings are:
22
23 TSALARM_CRITICAL critical
24
25
26 TSALARM_MAJOR major
27
28
29 TSALARM_MINOR minor
30
31
32 TSALARM_USER user
33
34
35
36 alarm_state
37
38 The state of the alarm. Valid settings are:
39
40 TSALARM_STATE_ON The alarm state needs to be changed to
41 "on", or is returned as "on".
42
43
44 TSALARM_STATE_OFF The alarm state needs to be changed to
45 "off", or is returned as "off".
46
47
48 TSALARM_STATE_UNKNOWN The alarm state is returned as unknown.
49
50
51
53 The TSALARM interface provides functions through which alarm relays can
54 be controlled. The set of functions and data structures of this inter‐
55 face are defined in the <tsalarm.h> header.
56
57
58 There are four alarm relays that are controlled by ILOM. Each alarm can
59 be set to "on" or "off" by using tsalarm interfaces provided from the
60 host. The four alarms are labeled as critical, major, minor, and user.
61 The user alarm is set by a user application depending on system condi‐
62 tion. LEDs in front of the box provide a visual indication of the four
63 alarms. The number of alarms and their meanings and labels can vary
64 across platforms.
65
66
67 The tsalarm_get() function gets the state of alarm_type and returnsit
68 in alarm_state. If successful, the function returns 0.
69
70
71 The tsalarm_set() function sets the state of alarm_type to the value in
72 alarm_state. If successful, the function returns 0.
73
74
75 The following structures are defined in <tsalarm.h>:
76
77 typedef struct tsalarm_req {
78 uint32_t alarm_id;
79 uint32_t alarm_action;
80 } tsalarm_req_t;
81
82
83 typedef struct tsalarm_resp {
84 uint32_t status;
85 uint32_t alarm_id;
86 uint32_t alarm_state;
87 } tsalarm_resp_t;
88
89
91 The tsalarm_get() and tsalarm_set() functions return the following val‐
92 ues:
93
94 TSALARM_CHANNEL_INIT_FAILURE
95
96 Channel initialization failed.
97
98
99 TSALARM_COMM_FAILURE
100
101 Channel communication failed.
102
103
104 TSALARM_NULL_REQ_DATA
105
106 Allocating memory for request data failed.
107
108
109 TSALARM_SUCCESS
110
111 Successful completion.
112
113
114 TSALARM_UNBOUND_PACKET_RECVD
115
116 An incorrect packet was received.
117
118
119
120 The tsalarm_get() function returns the following value:
121
122 TSALARM_GET_ERROR An error occurred while getting the alarm state.
123
124
125
126 The tsalarm_set() function returns the following value:
127
128 TSALARM_SET_ERROR An error occurred while setting the alarm state.
129
130
132 Example 1 Get and set an alarm state.
133
134
135 The following example demonstrates how to get and set an alarm state.
136
137
138 #include <stdio.h>
139 #include <stdlib.h>
140 #include <string.h>
141 #include <sys/types.h>
142 #include <tsalarm.h>
143
144 void help(char *name) {
145 printf("Syntax: %s [get <type> | set <type> <state>]\n\n", name);
146 printf(" type = { critical, major, minor, user }\n");
147 printf(" state = { on, off }\n\n");
148
149 exit(0);
150 }
151
152 int main(int argc, char **argv) {
153
154 uint32_t alarm_type, alarm_state;
155
156 if (argc < 3)
157 help(argv[0]);
158
159 if (strncmp(argv[2], "critical", 1) == 0)
160 alarm_type = TSALARM_CRITICAL;
161 else if (strncmp(argv[2], "major", 2) == 0)
162 alarm_type = TSALARM_MAJOR;
163 else if (strncmp(argv[2], "minor", 2) == 0)
164 alarm_type = TSALARM_MINOR;
165 else if (strncmp(argv[2], "user", 1) == 0)
166 alarm_type = TSALARM_USER;
167 else
168 help(argv[0]);
169
170 if (strncmp(argv[1], "get", 1) == 0) {
171 tsalarm_get(alarm_type, &alarm_state);
172 printf("alarm = %d\tstate = %d\n", alarm_type, alarm_state);
173 }
174 else if (strncmp(argv[1], "set", 1) == 0) {
175 if (strncmp(argv[3], "on", 2) == 0)
176 alarm_state = TSALARM_STATE_ON;
177 else if (strncmp(argv[3], "off", 2) == 0)
178 alarm_state = TSALARM_STATE_OFF;
179 else
180 help(argv[0]);
181
182 tsalarm_set(alarm_type, alarm_state);
183 }
184 else {
185 help(argv[0]);
186 }
187
188 return 0;
189 }
190
191
193 See attributes(5) for descriptions of the following attributes:
194
195
196
197
198 ┌─────────────────────────────┬─────────────────────────────┐
199 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
200 ├─────────────────────────────┼─────────────────────────────┤
201 │Interface Stability │Uncommitted │
202 ├─────────────────────────────┼─────────────────────────────┤
203 │MT-Level │Safe │
204 └─────────────────────────────┴─────────────────────────────┘
205
207 libtsalarm(3LIB), attributes(5)
208
209
210
211SunOS 5.11 4 Sep 2007 tsalarm_get(3EXT)