1 | /*
|
---|
2 | * TOPPERS ECHONET Lite Communication Middleware
|
---|
3 | *
|
---|
4 | * Copyright (C) 2014-2016 Cores Co., Ltd. Japan
|
---|
5 | *
|
---|
6 | * ä¸è¨èä½æ¨©è
|
---|
7 | ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
|
---|
8 | * ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹
|
---|
9 | * å¤ã»åé
|
---|
10 | å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
11 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
12 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
13 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
14 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
15 | * ç¨ã§ããå½¢ã§åé
|
---|
16 | å¸ããå ´åã«ã¯ï¼åé
|
---|
17 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
18 | * è
|
---|
19 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
20 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
21 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
22 | * ç¨ã§ããªãå½¢ã§åé
|
---|
23 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
24 | * ã¨ï¼
|
---|
25 | * (a) åé
|
---|
26 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
27 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
28 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
29 | * (b) åé
|
---|
30 | å¸ã®å½¢æ
|
---|
31 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
32 | * å ±åãããã¨ï¼
|
---|
33 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
34 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
35 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
36 | 責ãããã¨ï¼
|
---|
37 | * ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
|
---|
38 | * ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
|
---|
39 | ããã³TOPPERSããã¸ã§ã¯ãã
|
---|
40 | * å
|
---|
41 | 責ãããã¨ï¼
|
---|
42 | *
|
---|
43 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
44 | ã
|
---|
45 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
|
---|
46 | * ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
|
---|
47 | * ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã
|
---|
48 | * ã®è²¬ä»»ãè² ããªãï¼
|
---|
49 | *
|
---|
50 | */
|
---|
51 |
|
---|
52 | /*
|
---|
53 | * ECHONET Lite ã¿ã¹ã¯ ãããã°åºå
|
---|
54 | */
|
---|
55 |
|
---|
56 | #include <mruby.h>
|
---|
57 | #include <stdio.h>
|
---|
58 | #include <stdlib.h>
|
---|
59 | #include <stdarg.h>
|
---|
60 | #include <string.h>
|
---|
61 | #include <ctype.h>
|
---|
62 |
|
---|
63 | #include "echonet.h"
|
---|
64 | #include "echonet_dbg.h"
|
---|
65 | #include "echonet_fbs.h"
|
---|
66 | #include "echonet_task.h"
|
---|
67 |
|
---|
68 | #ifdef ECN_DBG_WAI_ENA
|
---|
69 | #define _ECN_DBG_WAI_SYSLOG _ecn_dbg_wai_syslog()
|
---|
70 | #else
|
---|
71 | #define _ECN_DBG_WAI_SYSLOG
|
---|
72 | #endif
|
---|
73 |
|
---|
74 | #if defined(ECN_DBG_PUT_ENA) || defined(ECN_CAP_PUT_ENA)
|
---|
75 | #if defined(ECN_DBG_WAI_ENA)
|
---|
76 | static ER _ecn_dbg_wai_syslog(void);
|
---|
77 | /*
|
---|
78 | * syslog()ãããã¡ã«ä½è£ãã§ããã¾ã§å¾
|
---|
79 | ã¤
|
---|
80 | */
|
---|
81 | static ER _ecn_dbg_wai_syslog(void)
|
---|
82 | {
|
---|
83 | T_SYSLOG_RLOG a_rlog;
|
---|
84 | ER a_ret;
|
---|
85 | int a_ct = 0;
|
---|
86 | #ifndef ECN_DBG_WAI_SYSLOG_RETRY
|
---|
87 | #ifdef LOGTASK
|
---|
88 | #define ECN_DBG_WAI_SYSLOG_RETRY 10
|
---|
89 | #else
|
---|
90 | #define ECN_DBG_WAI_SYSLOG_RETRY 0
|
---|
91 | #endif
|
---|
92 | #endif
|
---|
93 |
|
---|
94 | for (;;) {
|
---|
95 | a_ret = syslog_ref_log(&a_rlog);
|
---|
96 | if (a_ret < 0)
|
---|
97 | return a_ret;
|
---|
98 | if (1 <= a_rlog.count) {
|
---|
99 | a_ct = 0;
|
---|
100 | } else
|
---|
101 | #if (defined ECN_DBG_WAI_SYSLOG_RETRY) && (0 < ECN_DBG_WAI_SYSLOG_RETRY)
|
---|
102 | if (ECN_DBG_WAI_SYSLOG_RETRY <= ++a_ct)
|
---|
103 | #endif
|
---|
104 | {
|
---|
105 | /* a_ret = dly_tsk(100);
|
---|
106 | if (a_ret < 0 && a_ret != E_RLWAI)
|
---|
107 | return a_ret; // */
|
---|
108 | break;
|
---|
109 | }
|
---|
110 |
|
---|
111 | a_ret = dly_tsk(1);
|
---|
112 | if (a_ret < 0 && a_ret != E_RLWAI)
|
---|
113 | return a_ret;
|
---|
114 | }
|
---|
115 | return 0;
|
---|
116 | }
|
---|
117 | #endif /* #if defined(ECN_DBG_WAI_ENA) */
|
---|
118 |
|
---|
119 | /*
|
---|
120 | * ãããã°åºå
|
---|
121 | * ä¾ï¼ ECN_DBG_PUT_2("task start");
|
---|
122 | */
|
---|
123 | int _ecn_dbg_dbgput(ecnl_svc_task_t *svc, const char *fp_srcloc, const char *fp_form, ...)
|
---|
124 | {
|
---|
125 | va_list v;
|
---|
126 | char *p_buf = 0;
|
---|
127 | #ifdef ECN_DBG_PUT_USE_STATIC
|
---|
128 | #ifndef SEM_ECN_DBG_PUT
|
---|
129 | /* 256byteãããã¡8æ¬ãã¼ãã¼ã·ã§ã³ */
|
---|
130 | static char a_buf[8][256];
|
---|
131 | static volatile uint_t a_buf_idx = 0;
|
---|
132 | uint_t a_buf_idx_a;
|
---|
133 | #else
|
---|
134 | /* ã»ããã©ãç¨ãã¦ã1æ¬ã®ãããã¡ä¸ã«æååã並ã¹ã¦ä½¿ã */
|
---|
135 | static char a_buf[1024];
|
---|
136 | static volatile uint_t a_buf_pos = 0;
|
---|
137 | size_t a_buf_len;
|
---|
138 | #define ECN_DBG_PUT_BUF_MAX a_buf_len
|
---|
139 | #endif /* #ifdef SEM_ECN_DBG_PUT */
|
---|
140 | #endif /* #ifdef ECN_DBG_PUT_USE_STATIC */
|
---|
141 | #ifndef ECN_DBG_PUT_BUF_MAX
|
---|
142 | #define ECN_DBG_PUT_BUF_MAX 255
|
---|
143 | #endif
|
---|
144 |
|
---|
145 | if (!fp_srcloc)
|
---|
146 | fp_srcloc = "(null)";
|
---|
147 |
|
---|
148 | #ifdef SEM_ECN_DBG_PUT
|
---|
149 | syscall(wai_sem(SEM_ECN_DBG_PUT));
|
---|
150 | #endif
|
---|
151 |
|
---|
152 | #ifdef ECN_DBG_PUT_USE_STATIC
|
---|
153 | #ifndef SEM_ECN_DBG_PUT
|
---|
154 | a_buf_idx_a = ++a_buf_idx;
|
---|
155 | p_buf = a_buf[a_buf_idx_a & 0x07];
|
---|
156 | #else
|
---|
157 | if (sizeof(a_buf) - a_buf_pos < 80) /* æ®ãã80byteæªæºã«ãªã£ãããå
|
---|
158 | é ã«æ»ã */
|
---|
159 | a_buf_pos = 0;
|
---|
160 | p_buf = a_buf + a_buf_pos;
|
---|
161 | a_buf_len = sizeof(a_buf) - a_buf_pos - 1;
|
---|
162 | if (80 * 2 <= a_buf_len) /* 80byte*2以ä¸ã®ä½ç½ããããã¡ã¯ãæ«å°¾80byteãæ®ã */
|
---|
163 | a_buf_len -= 80;
|
---|
164 | #endif /* #ifdef SEM_ECN_DBG_PUT */
|
---|
165 | #else
|
---|
166 | p_buf = (char *)_ecn_fbs_mbx_get(mrb, 255);
|
---|
167 | if (!p_buf) {
|
---|
168 | printf("%s: (+mbx fault) %s", fp_srcloc, fp_form);
|
---|
169 | #ifdef SEM_ECN_DBG_PUT
|
---|
170 | syscall(sig_sem(SEM_ECN_DBG_PUT));
|
---|
171 | #endif /* #ifdef SEM_ECN_DBG_PUT */
|
---|
172 | return 1;
|
---|
173 | }
|
---|
174 | #endif /* #ifdef ECN_DBG_PUT_USE_STATIC */
|
---|
175 |
|
---|
176 | va_start(v, fp_form);
|
---|
177 |
|
---|
178 | #ifdef _MSC_VER
|
---|
179 | vsnprintf_s(p_buf, ECN_DBG_PUT_BUF_MAX, ECN_DBG_PUT_BUF_MAX, fp_form, v);
|
---|
180 | #else
|
---|
181 | vsprintf(p_buf, fp_form, v);
|
---|
182 | #endif
|
---|
183 | #ifdef ECN_DBG_PUT_USE_STATIC
|
---|
184 | #ifdef SEM_ECN_DBG_PUT
|
---|
185 | a_buf_len = strlen(p_buf) + 1;
|
---|
186 | /* æ®ãã80byteæªæºã«ãªã£ãã */
|
---|
187 | if (sizeof(a_buf) - a_buf_pos - a_buf_len < 80) {
|
---|
188 | /* å
|
---|
189 | é ã«æ»ã */
|
---|
190 | a_buf_pos = 0;
|
---|
191 | } else {
|
---|
192 | a_buf_pos += a_buf_len;
|
---|
193 | }
|
---|
194 | #endif /* #ifdef SEM_ECN_DBG_PUT */
|
---|
195 | #endif
|
---|
196 |
|
---|
197 | _ECN_DBG_WAI_SYSLOG; /* syslog()ãããã¡ã«ä½è£ãã§ããã¾ã§å¾
|
---|
198 | 㤠*/
|
---|
199 |
|
---|
200 | #ifdef SEM_ECN_DBG_PUT
|
---|
201 | syscall(sig_sem(SEM_ECN_DBG_PUT));
|
---|
202 | #endif
|
---|
203 |
|
---|
204 | printf("%s: %s", fp_srcloc, p_buf);
|
---|
205 |
|
---|
206 | va_end(v);
|
---|
207 |
|
---|
208 | #ifndef ECN_DBG_PUT_USE_STATIC
|
---|
209 | _ecn_fbs_mbx_rel(mrb, p_buf);
|
---|
210 | #endif
|
---|
211 | return 0;
|
---|
212 | }
|
---|
213 |
|
---|
214 | /* ECN_ENOD_IDã®æååå¤æ */
|
---|
215 | const char *_ecn_dbg_enod2str(ECN_ENOD_ID fa_enod_id)
|
---|
216 | {
|
---|
217 | /* #define _ECN_FBS_DBG_ENOD2STR_BUF_MAX_BIT (4)
|
---|
218 | /* */
|
---|
219 | #ifdef _ECN_FBS_DBG_ENOD2STR_BUF_MAX_BIT
|
---|
220 | static volatile uint8_t a_idx_vol = 0;
|
---|
221 | static char a_buf[1 << _ECN_FBS_DBG_ENOD2STR_BUF_MAX_BIT][sizeof("ENOD_REMOTE_ID()")+5];
|
---|
222 | uint8_t a_idx;
|
---|
223 | #endif
|
---|
224 |
|
---|
225 | if (fa_enod_id == ENOD_NOT_MATCH_ID)
|
---|
226 | return "ENOD_NOT_MATCH_ID";
|
---|
227 | if (fa_enod_id == ENOD_MULTICAST_ID)
|
---|
228 | return "ENOD_MULTICAST_ID";
|
---|
229 | if (fa_enod_id == ENOD_LOCAL_ID)
|
---|
230 | return "ENOD_LOCAL_ID";
|
---|
231 | if (fa_enod_id == ENOD_API_ID)
|
---|
232 | return "ENOD_API_ID";
|
---|
233 | if (fa_enod_id == ENOD_REMOTE_ID)
|
---|
234 | return "ENOD_REMOTE_ID(0)";
|
---|
235 | if (fa_enod_id == ((ENOD_REMOTE_ID) + 1))
|
---|
236 | return "ENOD_REMOTE_ID(1)";
|
---|
237 | if (fa_enod_id == ((ENOD_REMOTE_ID) + 2))
|
---|
238 | return "ENOD_REMOTE_ID(2)";
|
---|
239 | if (fa_enod_id == ((ENOD_REMOTE_ID) + 3))
|
---|
240 | return "ENOD_REMOTE_ID(3)";
|
---|
241 | if (fa_enod_id == ((ENOD_REMOTE_ID) + 4))
|
---|
242 | return "ENOD_REMOTE_ID(4)";
|
---|
243 | if (fa_enod_id == ((ENOD_REMOTE_ID) + 5))
|
---|
244 | return "ENOD_REMOTE_ID(5)";
|
---|
245 | #ifdef _ECN_FBS_DBG_ENOD2STR_BUF_MAX_BIT
|
---|
246 | if (ENOD_REMOTE_ID <= fa_enod_id) {
|
---|
247 | /* return "ENOD_REMOTE_ID"; */
|
---|
248 | a_idx = (++a_idx_vol) & ((1 << _ECN_FBS_DBG_ENOD2STR_BUF_MAX_BIT) - 1);
|
---|
249 | #ifdef _MSC_VER
|
---|
250 | sprintf_s(a_buf[a_idx], sizeof(*a_buf), "ENOD_REMOTE_ID(%d)", fa_enod_id - ENOD_REMOTE_ID);
|
---|
251 | #else
|
---|
252 | sprintf(a_buf[a_idx], "ENOD_REMOTE_ID(%d)", fa_enod_id - ENOD_REMOTE_ID);
|
---|
253 | #endif
|
---|
254 | return a_buf[a_idx];
|
---|
255 | }
|
---|
256 | #endif
|
---|
257 |
|
---|
258 | return "?";
|
---|
259 | }
|
---|
260 |
|
---|
261 | /*
|
---|
262 | * ãã¤ããªãã³ãåºå
|
---|
263 | */
|
---|
264 | void _ecn_dbg_bindmp(const uint8_t *buffer, size_t len)
|
---|
265 | {
|
---|
266 | /* staticé åã®ãããã¡ãåãæ¿ããåæ°(2^n) */
|
---|
267 | #define _ECN_FBS_DBG_BINDMP_BUF_MAX_BIT (4)
|
---|
268 | /* */
|
---|
269 | #ifdef SEM_ECN_DBG_BINDMP
|
---|
270 | #ifdef _ECN_FBS_DBG_BINDMP_BUF_MAX_BIT
|
---|
271 | #undef _ECN_FBS_DBG_BINDMP_BUF_MAX_BIT
|
---|
272 | /* ã»ããã©(SEM_ECN_DBG_BINDMP)ãå®ç¾©ããã¦ããå ´åããããã¡åãæ¿ãã¯ä¸è¦ãªã®ã§undef */
|
---|
273 | #endif
|
---|
274 | #endif
|
---|
275 | #ifndef _ECN_FBS_DBG_BINDMP_BUFLEN
|
---|
276 | /* ãããã¡ãµã¤ãº(bindmpä¸ã®1è¡ãåã¾ããµã¤ãº) */
|
---|
277 | #define _ECN_FBS_DBG_BINDMP_BUFLEN (80)
|
---|
278 | #endif
|
---|
279 | #ifdef _ECN_FBS_DBG_BINDMP_BUF_MAX_BIT
|
---|
280 | /* staticé åã®ãããã¡ãåãæ¿ããããã®ç®¡çç¨å¤æ° */
|
---|
281 | static volatile uint8_t a_idx_vol = 0;
|
---|
282 | /* staticé åã®ãããã¡åãæ¿ãé å */
|
---|
283 | static char a_buf_area[1 << _ECN_FBS_DBG_BINDMP_BUF_MAX_BIT][_ECN_FBS_DBG_BINDMP_BUFLEN];
|
---|
284 | uint8_t a_idx;
|
---|
285 | char *a_buf;
|
---|
286 | #else
|
---|
287 | /* staticé åã®ãããã¡é å */
|
---|
288 | static char a_buf[_ECN_FBS_DBG_BINDMP_BUFLEN];
|
---|
289 | #endif
|
---|
290 | const uint8_t *p = buffer; /* èªã¿åããã¤ã³ã¿ */
|
---|
291 | int i, a_blk, a_blk_max, a_pos = 0;
|
---|
292 | const T_ECN_EDT_HDR *p_req_esv;
|
---|
293 | const T_ECN_INTERNAL_MSG *p_im;
|
---|
294 |
|
---|
295 | #ifdef SEM_ECN_DBG_BINDMP
|
---|
296 | syscall(wai_sem(SEM_ECN_DBG_BINDMP));
|
---|
297 | #endif
|
---|
298 |
|
---|
299 | if (len != 256) {
|
---|
300 | a_blk_max = 1;
|
---|
301 | } else {
|
---|
302 | a_blk_max = ((T_ECN_FST_BLK *)buffer)->hdr.wr;
|
---|
303 | if (!a_blk_max)
|
---|
304 | a_blk_max = 1;
|
---|
305 | }
|
---|
306 | #ifndef ECN_DBG_BINDMP_MAXLEN
|
---|
307 | /* bindmpåºåã®æ大ãµã¤ãº */
|
---|
308 | #define ECN_DBG_BINDMP_MAXLEN 1600
|
---|
309 | #endif
|
---|
310 | if (ECN_DBG_BINDMP_MAXLEN < len) {
|
---|
311 | len = ECN_DBG_BINDMP_MAXLEN;
|
---|
312 | }
|
---|
313 |
|
---|
314 | #ifdef _ECN_FBS_DBG_BINDMP_BUF_MAX_BIT
|
---|
315 | a_idx = (++a_idx_vol) & ((1 << _ECN_FBS_DBG_BINDMP_BUF_MAX_BIT) - 1);
|
---|
316 | a_buf = a_buf_area[a_idx];
|
---|
317 | /* #define a_buf (a_buf_area[a_idx]) */
|
---|
318 | #endif
|
---|
319 |
|
---|
320 | for (a_blk = 0; p && a_blk < a_blk_max; p = ((T_ECN_FST_BLK *)buffer)->lnk.p_sub[a_blk++]->payload) {
|
---|
321 | if (0 < a_blk) {
|
---|
322 | _ECN_DBG_WAI_SYSLOG; /* syslog()ãããã¡ã«ä½è£ãã§ããã¾ã§å¾
|
---|
323 | 㤠*/
|
---|
324 | printf("p_sub[%d] (0x%p)", a_blk - 1, p);
|
---|
325 | }
|
---|
326 | memset(a_buf, 0, _ECN_FBS_DBG_BINDMP_BUFLEN);
|
---|
327 | for (i = 0; i < (int)len; i++) {
|
---|
328 | if (i % 16 == 0) {
|
---|
329 | if (a_buf[0]) {
|
---|
330 | _ECN_DBG_WAI_SYSLOG; /* syslog()ãããã¡ã«ä½è£ãã§ããã¾ã§å¾
|
---|
331 | 㤠*/
|
---|
332 | printf("%s", a_buf);
|
---|
333 | }
|
---|
334 | #ifdef _MSC_VER
|
---|
335 | sprintf_s(a_buf, _ECN_FBS_DBG_BINDMP_BUFLEN, "[%08X]:", i);
|
---|
336 | #else
|
---|
337 | sprintf(a_buf, "[%08X]:", i);
|
---|
338 | #endif
|
---|
339 | a_pos = strlen(a_buf);
|
---|
340 | } else {
|
---|
341 | a_buf[a_pos++] = (i % 16 == 8 ? '-':' ');
|
---|
342 | }
|
---|
343 | #ifdef _MSC_VER
|
---|
344 | sprintf_s(a_buf + a_pos, _ECN_FBS_DBG_BINDMP_BUFLEN - a_pos, "%02X", p[i]);
|
---|
345 | #else
|
---|
346 | sprintf(a_buf + a_pos, "%02X", p[i]);
|
---|
347 | #endif
|
---|
348 | a_pos += 2;
|
---|
349 | }
|
---|
350 | if (a_buf[0]) {
|
---|
351 | _ECN_DBG_WAI_SYSLOG; /* syslog()ãããã¡ã«ä½è£ãã§ããã¾ã§å¾
|
---|
352 | 㤠*/
|
---|
353 | printf("%s", a_buf);
|
---|
354 | }
|
---|
355 | if (a_blk_max == 1)
|
---|
356 | break;
|
---|
357 | }
|
---|
358 |
|
---|
359 | if (len == 256) {
|
---|
360 | switch (((const T_ECN_FST_BLK *)buffer)->hdr.type) {
|
---|
361 | case ECN_MSG_ECHONET:
|
---|
362 | p_req_esv = (T_ECN_EDT_HDR *)&((const T_ECN_FST_BLK *)buffer)->payload;
|
---|
363 | _ECN_DBG_WAI_SYSLOG; /* syslog()ãããã¡ã«ä½è£ãã§ããã¾ã§å¾
|
---|
364 | 㤠*/
|
---|
365 | printf(" sender: %d %s, target: %d %s",
|
---|
366 | ((T_ECN_FST_BLK *)buffer)->hdr.sender.id, _ecn_dbg_enod2str(((T_ECN_FST_BLK *)buffer)->hdr.sender.id),
|
---|
367 | ((T_ECN_FST_BLK *)buffer)->hdr.target.id, _ecn_dbg_enod2str(((T_ECN_FST_BLK *)buffer)->hdr.target.id));
|
---|
368 | _ECN_DBG_WAI_SYSLOG; /* syslog()ãããã¡ã«ä½è£ãã§ããã¾ã§å¾
|
---|
369 | 㤠*/
|
---|
370 | printf(" ecn_hdr: 0x%02X 0x%02X 0x%04X", p_req_esv->ecn_hdr.ehd1, p_req_esv->ecn_hdr.ehd2, p_req_esv->ecn_hdr.tid);
|
---|
371 | _ECN_DBG_WAI_SYSLOG; /* syslog()ãããã¡ã«ä½è£ãã§ããã¾ã§å¾
|
---|
372 | 㤠*/
|
---|
373 | printf(" edata: 0x%06X 0x%06X 0x%02X 0x%02X (%s)",
|
---|
374 | p_req_esv->edata.seoj.eojx1 << 16 | p_req_esv->edata.seoj.eojx2 << 8 | p_req_esv->edata.seoj.eojx3,
|
---|
375 | p_req_esv->edata.deoj.eojx1 << 16 | p_req_esv->edata.deoj.eojx2 << 8 | p_req_esv->edata.deoj.eojx3,
|
---|
376 | p_req_esv->edata.esv, p_req_esv->edata.opc, _ecn_dbg_esv2str(p_req_esv->edata.esv));
|
---|
377 | _ECN_DBG_WAI_SYSLOG; /* syslog()ãããã¡ã«ä½è£ãã§ããã¾ã§å¾
|
---|
378 | 㤠*/
|
---|
379 | printf(" ecn_prp: 0x%02X 0x%02X", p_req_esv->ecn_prp.epc, p_req_esv->ecn_prp.pdc);
|
---|
380 | _ECN_DBG_WAI_SYSLOG; /* syslog()ãããã¡ã«ä½è£ãã§ããã¾ã§å¾
|
---|
381 | 㤠*/
|
---|
382 | printf(" cur(blk/pos): wr %d, rd %d",
|
---|
383 | (int)((T_ECN_FST_BLK *)buffer)->hdr.wr,
|
---|
384 | (int)((T_ECN_FST_BLK *)buffer)->hdr.rd);
|
---|
385 | break;
|
---|
386 | case ECN_MSG_INTERNAL:
|
---|
387 | p_im = (const T_ECN_INTERNAL_MSG *)&((const T_ECN_FST_BLK *)buffer)->payload[0];
|
---|
388 | printf(" a_im.command: %d:%s", p_im->command,
|
---|
389 | (p_im->command == ECN_INM_NOTIFY_INSTANCELIST ? "ECN_INM_NOTIFY_INSTANCELIST":
|
---|
390 | (p_im->command == ECN_INM_GET_DEVICE_LIST_REQ ? "ECN_INM_GET_DEVICE_LIST_REQ" :
|
---|
391 | (p_im->command == ECN_INM_GET_DEVICE_LIST_RES ? "ECN_INM_GET_DEVICE_LIST_RES" :
|
---|
392 | (p_im->command == ECN_INM_GET_DEVICE_INFO_REQ ? "ECN_INM_GET_DEVICE_INFO_REQ " :
|
---|
393 | (p_im->command == ECN_INM_GET_DEVICE_INFO_RES ? "ECN_INM_GET_DEVICE_INFO_RES " :
|
---|
394 | (p_im->command == ECN_LCL_MSG_GET_LCLADDR_REQ ? "ECN_LCL_MSG_GET_LCLADDR_REQ " :
|
---|
395 | (p_im->command == ECN_LCL_MSG_GET_LCLADDR_REQ ? "ECN_LCL_MSG_GET_LCLADDR_REQ " :
|
---|
396 | (p_im->command == ECN_LCL_MSG_GET_LCLADDR_ERROR ? "ECN_LCL_MSG_GET_LCLADDR_ERROR" : "?")))))))));
|
---|
397 | memset(a_buf, 0, _ECN_FBS_DBG_BINDMP_BUFLEN);
|
---|
398 | a_blk_max = ((const T_ECN_FST_BLK *)buffer)->hdr.wr;
|
---|
399 | if (0 < a_blk_max) {
|
---|
400 | if (64 < a_blk_max)
|
---|
401 | a_blk_max = 64;
|
---|
402 | if (_ECN_FBS_DBG_BINDMP_BUFLEN < a_blk_max)
|
---|
403 | a_blk_max = _ECN_FBS_DBG_BINDMP_BUFLEN;
|
---|
404 | for (i = offsetof(T_ECN_INTERNAL_MSG, data); i < a_blk_max; i++) {
|
---|
405 | a_blk = ((const T_ECN_FST_BLK *)buffer)->payload[i];
|
---|
406 | if (!isprint(a_blk) || !isascii(a_blk))
|
---|
407 | a_blk = '.';
|
---|
408 | a_buf[i - 1] = a_blk;
|
---|
409 | }
|
---|
410 | printf(" a_im.data: [%s]", &a_buf[offsetof(T_ECN_INTERNAL_MSG, data) - 1]);
|
---|
411 | }
|
---|
412 | break;
|
---|
413 | default:
|
---|
414 | printf(" invalid type: %d", ((const T_ECN_FST_BLK *)buffer)->hdr.type);
|
---|
415 | }
|
---|
416 | }
|
---|
417 | else if (8 <= len
|
---|
418 | && ((const T_ECN_FST_BLK *)buffer)->payload[0] == 0x10
|
---|
419 | && ((const T_ECN_FST_BLK *)buffer)->payload[1] == 0x81) {
|
---|
420 | p_req_esv = (const T_ECN_EDT_HDR *)&((const T_ECN_FST_BLK *)buffer)->payload[0];
|
---|
421 | _ECN_DBG_WAI_SYSLOG; /* syslog()ãããã¡ã«ä½è£ãã§ããã¾ã§å¾
|
---|
422 | 㤠*/
|
---|
423 | printf(" ecn_hdr: 0x%02X 0x%02X 0x%04X", p_req_esv->ecn_hdr.ehd1, p_req_esv->ecn_hdr.ehd2, p_req_esv->ecn_hdr.tid);
|
---|
424 | _ECN_DBG_WAI_SYSLOG; /* syslog()ãããã¡ã«ä½è£ãã§ããã¾ã§å¾
|
---|
425 | 㤠*/
|
---|
426 | printf(" edata: 0x%06X 0x%06X 0x%02X 0x%02X (%s)",
|
---|
427 | p_req_esv->edata.seoj.eojx1 << 16 | p_req_esv->edata.seoj.eojx2 << 8 | p_req_esv->edata.seoj.eojx3,
|
---|
428 | p_req_esv->edata.deoj.eojx1 << 16 | p_req_esv->edata.deoj.eojx2 << 8 | p_req_esv->edata.deoj.eojx3,
|
---|
429 | p_req_esv->edata.esv, p_req_esv->edata.opc, _ecn_dbg_esv2str(p_req_esv->edata.esv));
|
---|
430 | _ECN_DBG_WAI_SYSLOG; /* syslog()ãããã¡ã«ä½è£ãã§ããã¾ã§å¾
|
---|
431 | 㤠*/
|
---|
432 | printf(" ecn_prp: 0x%02X 0x%02X", p_req_esv->ecn_prp.epc, p_req_esv->ecn_prp.pdc);
|
---|
433 | }
|
---|
434 | #ifdef SEM_ECN_DBG_BINDMP
|
---|
435 | syscall(sig_sem(SEM_ECN_DBG_BINDMP));
|
---|
436 | #endif
|
---|
437 | }
|
---|
438 |
|
---|
439 | /*
|
---|
440 | * ECHONET Liteãµã¼ãã¹ã³ã¼ãæååå¤æ
|
---|
441 | */
|
---|
442 | const char *_ecn_dbg_esv2str(uint8_t fa_esv)
|
---|
443 | {
|
---|
444 | switch (fa_esv) {
|
---|
445 | case ESV_SET_I_SNA: return "ããããã£å¤æ¸ãè¾¼ã¿è¦æ±ä¸å¯å¿ç"; /* 0x50 */
|
---|
446 | case ESV_SET_C_SNA: return "ããããã£å¤æ¸ãè¾¼ã¿è¦æ±ä¸å¯å¿ç"; /* 0x51 */
|
---|
447 | case ESV_GET_SNA: return "ããããã£å¤èªã¿åºãä¸å¯å¿ç"; /* 0x52 */
|
---|
448 | case ESV_INF_SNA: return "ããããã£å¤éç¥ä¸å¯å¿ç"; /* 0x53 */
|
---|
449 | case ESV_SET_GET_SNA: return "ããããã£å¤æ¸ãè¾¼ã¿ã»èªã¿åºãä¸å¯å¿ç"; /* 0x5E */
|
---|
450 | case ESV_SET_I: return "ããããã£å¤æ¸ãè¾¼ã¿è¦æ±ï¼å¿çä¸è¦ï¼"; /* 0x60 */
|
---|
451 | case ESV_SET_C: return "ããããã£å¤æ¸ãè¾¼ã¿è¦æ±ï¼å¿çè¦ï¼"; /* 0x61 */
|
---|
452 | case ESV_GET: return "ããããã£å¤èªã¿åºãè¦æ±"; /* 0x62 */
|
---|
453 | case ESV_INF_REQ: return "ããããã£å¤éç¥è¦æ±"; /* 0x63 */
|
---|
454 | case ESV_SET_GET: return "ããããã£å¤æ¸ãè¾¼ã¿ã»èªã¿åºãè¦æ±"; /* 0x6E */
|
---|
455 | case ESV_SET_RES: return "ããããã£å¤æ¸ãè¾¼ã¿å¿ç"; /* 0x71 */
|
---|
456 | case ESV_GET_RES: return "ããããã£å¤èªã¿åºãå¿ç"; /* 0x72 */
|
---|
457 | case ESV_INF: return "ããããã£å¤éç¥"; /* 0x73 */
|
---|
458 | case ESV_INFC: return "ããããã£å¤éç¥ï¼å¿çè¦ï¼"; /* 0x74 */
|
---|
459 | case ESV_SET_GET_RES: return "ããããã£å¤æ¸ãè¾¼ã¿ã»èªã¿åºãå¿ç"; /* 0x7E */
|
---|
460 | case ESV_INFC_RES: return "ããããã£å¤éç¥å¿ç"; /* 0x7A */
|
---|
461 | default:
|
---|
462 | return "(unknown)";
|
---|
463 | }
|
---|
464 | }
|
---|
465 |
|
---|
466 | const char *itron_strerror(int errorno)
|
---|
467 | {
|
---|
468 | switch (errorno) {
|
---|
469 | case E_SYS: return "ã·ã¹ãã ã¨ã©ã¼";
|
---|
470 | case E_PAR: return "ãã©ã¡ã¼ã¿ã¨ã©ã¼";
|
---|
471 | case E_NOMEM: return "ã¡ã¢ãªä¸è¶³";
|
---|
472 | case E_OBJ: return "ãªãã¸ã§ã¯ãç¶æ
|
---|
473 | ã¨ã©ã¼";
|
---|
474 | case E_NOEXS: return "ãªãã¸ã§ã¯ãæªçæ";
|
---|
475 | case E_TMOUT: return "ãã¼ãªã³ã°å¤±æã¾ãã¯ã¿ã¤ã ã¢ã¦ã";
|
---|
476 | case E_BOVR: return "ãããã¡ãªã¼ãã¼ããã¼";
|
---|
477 | case E_BRK: return "ã¦ã¼ã¶ã¼ã«ããä¸æ";
|
---|
478 | default:
|
---|
479 | return "(unknown)";
|
---|
480 | }
|
---|
481 | }
|
---|
482 |
|
---|
483 | #endif /* #if defined(ECN_DBG_PUT_ENA) || defined(ECN_CAP_PUT_ENA) */
|
---|