source: uKadecot/trunk/ecnl_ssp/echonet_dbg.c@ 101

Last change on this file since 101 was 101, checked in by coas-nagasima, 8 years ago

TOPPERS/uKadecotのソースコードを追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/plain
File size: 14.5 KB
Line 
1/*
2 * TOPPERS ECHONET Lite Communication Middleware
3 *
4 * Copyright (C) 2014 Cores Co., Ltd. Japan
5 *
6 * ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
7 * ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
8 * •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
9 * (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
10 * Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
11 * ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
12 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
13 * —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
14ƒƒ“ƒgi—˜—p
15 * ŽÒƒ}ƒjƒ…
16ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
17 * ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
18 * (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
19 * —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
20 * ‚ƁD
21 * (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
22ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
23ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
24 * ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
25 * (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
26 * •ñ‚·‚邱‚ƁD
27 * (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
28 * ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
29 * ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
30 * —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
31 * –Ɛӂ·‚邱‚ƁD
32 *
33 * –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
34 * ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
35 * ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
36 * ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
37 * ‚̐ӔC‚𕉂í‚È‚¢D
38 *
39 * @(#) $Id: echonet_dbg.c 101 2015-06-02 15:37:23Z coas-nagasima $
40 */
41
42/*
43 * ECHONET Lite ƒ^ƒXƒN ƒfƒoƒbƒOo—Í
44 */
45
46#include <kernel.h>
47#include <stdio.h>
48#include <stdlib.h>
49#include <stdarg.h>
50#include <string.h>
51#include <t_syslog.h>
52#include <sil.h>
53#include <ctype.h>
54
55#include "syssvc/serial.h"
56#include "syssvc/syslog.h"
57
58#include "echonet.h"
59#include "echonet_dbg.h"
60#include "echonet_fbs.h"
61#include "echonet_task.h"
62
63#ifdef ECN_DBG_WAI_ENA
64#define _ECN_DBG_WAI_SYSLOG _ecn_dbg_wai_syslog()
65#else
66#define _ECN_DBG_WAI_SYSLOG
67#endif
68
69#if defined(ECN_DBG_PUT_ENA) || defined(ECN_CAP_PUT_ENA)
70#if defined(ECN_DBG_WAI_ENA)
71static ER _ecn_dbg_wai_syslog(void);
72/*
73 * syslog()ƒoƒbƒtƒ@‚É—]—T‚ª‚Å‚«‚é‚Ü‚Å‘Ò‚Â
74 */
75static ER _ecn_dbg_wai_syslog(void)
76{
77 T_SYSLOG_RLOG a_rlog;
78 ER a_ret;
79 int a_ct = 0;
80#ifndef ECN_DBG_WAI_SYSLOG_RETRY
81 #ifdef LOGTASK
82 #define ECN_DBG_WAI_SYSLOG_RETRY 10
83 #else
84 #define ECN_DBG_WAI_SYSLOG_RETRY 0
85 #endif
86#endif
87
88 for (;;) {
89 a_ret = syslog_ref_log(&a_rlog);
90 if (a_ret < 0)
91 return a_ret;
92 if (1 <= a_rlog.count) {
93 a_ct = 0;
94 } else
95#if (defined ECN_DBG_WAI_SYSLOG_RETRY) && (0 < ECN_DBG_WAI_SYSLOG_RETRY)
96 if (ECN_DBG_WAI_SYSLOG_RETRY <= ++a_ct)
97#endif
98 {
99/* a_ret = dly_tsk(100);
100 if (a_ret < 0 && a_ret != E_RLWAI)
101 return a_ret; // */
102 break;
103 }
104
105 a_ret = dly_tsk(1);
106 if (a_ret < 0 && a_ret != E_RLWAI)
107 return a_ret;
108 }
109 return 0;
110}
111#endif /* #if defined(ECN_DBG_WAI_ENA) */
112
113/*
114 * ƒfƒoƒbƒOo—Í
115 * —áF ECN_DBG_PUT "task start" ECN_DBG_END;
116 */
117int _ecn_dbg_dbgput(const char *fp_srcloc, const char *fp_form, ...)
118{
119 va_list v;
120 char *p_buf = 0;
121 ID tskid;
122#ifdef ECN_DBG_PUT_USE_STATIC
123 #ifndef SEM_ECN_DBG_PUT
124 /* 256byteƒoƒbƒtƒ@8–{ƒ[ƒe[ƒVƒ‡ƒ“ */
125 static char a_buf[8][256];
126 static volatile uint_t a_buf_idx = 0;
127 uint_t a_buf_idx_a;
128 #else
129 /* ƒZƒ}ƒtƒH‚ð—p‚¢‚āA1–{‚̃oƒbƒtƒ@ã‚É•¶Žš—ñ‚ð•À‚ׂĎg‚¤ */
130 static char a_buf[1024];
131 static volatile uint_t a_buf_pos = 0;
132 size_t a_buf_len;
133 #define ECN_DBG_PUT_BUF_MAX a_buf_len
134 #endif /* #ifdef SEM_ECN_DBG_PUT */
135#endif /* #ifdef ECN_DBG_PUT_USE_STATIC */
136#ifndef ECN_DBG_PUT_BUF_MAX
137 #define ECN_DBG_PUT_BUF_MAX 255
138#endif
139
140 get_tid(&tskid);
141
142 if (!fp_srcloc)
143 fp_srcloc = "(null)";
144
145#ifdef SEM_ECN_DBG_PUT
146 syscall(wai_sem(SEM_ECN_DBG_PUT));
147#endif
148
149#ifdef ECN_DBG_PUT_USE_STATIC
150 #ifndef SEM_ECN_DBG_PUT
151 a_buf_idx_a = ++a_buf_idx;
152 p_buf = a_buf[a_buf_idx_a & 0x07];
153 #else
154 if (sizeof(a_buf) - a_buf_pos < 80) /* Žc‚肪80byte–¢–ž‚É‚È‚Á‚½‚çAæ“ª‚É–ß‚é */
155 a_buf_pos = 0;
156 p_buf = a_buf + a_buf_pos;
157 a_buf_len = sizeof(a_buf) - a_buf_pos - 1;
158 if (80 * 2 <= a_buf_len) /* 80byte*2ˆÈã‚Ì—]”’‚ª‚ ‚邤‚¿‚́A––”ö80byte‚ðŽc‚· */
159 a_buf_len -= 80;
160 #endif /* #ifdef SEM_ECN_DBG_PUT */
161#else
162 p_buf = (char *)_ecn_fbs_mbx_get(255);
163 if (!p_buf) {
164 syslog(LOG_NOTICE, "%s[%d]: (+mbx fault) %s", fp_srcloc, (int)tskid, fp_form);
165 #ifdef SEM_ECN_DBG_PUT
166 syscall(sig_sem(SEM_ECN_DBG_PUT));
167 #endif /* #ifdef SEM_ECN_DBG_PUT */
168 return 1;
169 }
170#endif /* #ifdef ECN_DBG_PUT_USE_STATIC */
171
172 va_start(v, fp_form);
173
174#ifdef _MSC_VER
175 vsnprintf_s(p_buf, ECN_DBG_PUT_BUF_MAX, ECN_DBG_PUT_BUF_MAX, fp_form, v);
176#else
177 vsprintf(p_buf, fp_form, v);
178#endif
179#ifdef ECN_DBG_PUT_USE_STATIC
180 #ifdef SEM_ECN_DBG_PUT
181 a_buf_len = strlen(p_buf) + 1;
182 /* Žc‚肪80byte–¢–ž‚É‚È‚Á‚½‚ç */
183 if (sizeof(a_buf) - a_buf_pos - a_buf_len < 80) {
184 /* æ“ª‚É–ß‚é */
185 a_buf_pos = 0;
186 } else {
187 a_buf_pos += a_buf_len;
188 }
189 #endif /* #ifdef SEM_ECN_DBG_PUT */
190#endif
191
192 _ECN_DBG_WAI_SYSLOG; /* syslog()ƒoƒbƒtƒ@‚É—]—T‚ª‚Å‚«‚é‚Ü‚Å‘Ò‚Â */
193
194#ifdef SEM_ECN_DBG_PUT
195 syscall(sig_sem(SEM_ECN_DBG_PUT));
196#endif
197
198 syslog(LOG_NOTICE, "%s[%d]: %s", fp_srcloc, (int)tskid, p_buf);
199
200 va_end(v);
201
202#ifndef ECN_DBG_PUT_USE_STATIC
203 _ecn_fbs_mbx_rel(p_buf);
204#endif
205 return 0;
206}
207
208/* ECN_ENOD_ID‚Ì•¶Žš—ñ•ÏŠ· */
209const char *_ecn_dbg_enod2str(ECN_ENOD_ID fa_enod_id)
210{
211/* #define _ECN_FBS_DBG_ENOD2STR_BUF_MAX_BIT (4)
212/* */
213#ifdef _ECN_FBS_DBG_ENOD2STR_BUF_MAX_BIT
214 static volatile uint8_t a_idx_vol = 0;
215 static char a_buf[1 << _ECN_FBS_DBG_ENOD2STR_BUF_MAX_BIT][sizeof("ENOD_REMOTE_ID()")+5];
216 uint8_t a_idx;
217#endif
218
219 if (fa_enod_id == ENOD_NOT_MATCH_ID)
220 return "ENOD_NOT_MATCH_ID";
221 if (fa_enod_id == ENOD_MULTICAST_ID)
222 return "ENOD_MULTICAST_ID";
223 if (fa_enod_id == ENOD_LOCAL_ID)
224 return "ENOD_LOCAL_ID";
225 if (fa_enod_id == ENOD_API_ID)
226 return "ENOD_API_ID";
227 if (fa_enod_id == ENOD_REMOTE_ID)
228 return "ENOD_REMOTE_ID(0)";
229 if (fa_enod_id == ((ENOD_REMOTE_ID) + 1))
230 return "ENOD_REMOTE_ID(1)";
231 if (fa_enod_id == ((ENOD_REMOTE_ID) + 2))
232 return "ENOD_REMOTE_ID(2)";
233 if (fa_enod_id == ((ENOD_REMOTE_ID) + 3))
234 return "ENOD_REMOTE_ID(3)";
235 if (fa_enod_id == ((ENOD_REMOTE_ID) + 4))
236 return "ENOD_REMOTE_ID(4)";
237 if (fa_enod_id == ((ENOD_REMOTE_ID) + 5))
238 return "ENOD_REMOTE_ID(5)";
239#ifdef _ECN_FBS_DBG_ENOD2STR_BUF_MAX_BIT
240 if (ENOD_REMOTE_ID <= fa_enod_id) {
241 /* return "ENOD_REMOTE_ID"; */
242 a_idx = (++a_idx_vol) & ((1 << _ECN_FBS_DBG_ENOD2STR_BUF_MAX_BIT) - 1);
243#ifdef _MSC_VER
244 sprintf_s(a_buf[a_idx], sizeof(*a_buf), "ENOD_REMOTE_ID(%d)", fa_enod_id - ENOD_REMOTE_ID);
245#else
246 sprintf(a_buf[a_idx], "ENOD_REMOTE_ID(%d)", fa_enod_id - ENOD_REMOTE_ID);
247#endif
248 return a_buf[a_idx];
249 }
250#endif
251
252 return "?";
253}
254
255/*
256 * ƒoƒCƒiƒŠƒ_ƒ“ƒvo—Í
257 */
258void _ecn_dbg_bindmp(const uint8_t *buffer, size_t len)
259{
260 /* static—̈æ‚̃oƒbƒtƒ@‚ðØ‚è‘Ö‚¦‚éŒÂ”(2^n) */
261 #define _ECN_FBS_DBG_BINDMP_BUF_MAX_BIT (4)
262/* */
263#ifdef SEM_ECN_DBG_BINDMP
264 #ifdef _ECN_FBS_DBG_BINDMP_BUF_MAX_BIT
265 #undef _ECN_FBS_DBG_BINDMP_BUF_MAX_BIT
266 /* ƒZƒ}ƒtƒH(SEM_ECN_DBG_BINDMP)‚ª’è‹`‚³‚ê‚Ä‚¢‚éê‡Aƒoƒbƒtƒ@Ø‚è‘Ö‚¦‚Í•s—v‚È‚Ì‚Åundef */
267 #endif
268#endif
269#ifndef _ECN_FBS_DBG_BINDMP_BUFLEN
270 /* ƒoƒbƒtƒ@ƒTƒCƒY(bindmp’†‚Ì1s‚ªŽû‚Ü‚éƒTƒCƒY) */
271 #define _ECN_FBS_DBG_BINDMP_BUFLEN (80)
272#endif
273#ifdef _ECN_FBS_DBG_BINDMP_BUF_MAX_BIT
274 /* static—̈æ‚̃oƒbƒtƒ@‚ðØ‚è‘Ö‚¦‚邽‚ß‚ÌŠÇ——p•Ï” */
275 static volatile uint8_t a_idx_vol = 0;
276 /* static—̈æ‚̃oƒbƒtƒ@Ø‚è‘Ö‚¦—̈æ */
277 static char a_buf_area[1 << _ECN_FBS_DBG_BINDMP_BUF_MAX_BIT][_ECN_FBS_DBG_BINDMP_BUFLEN];
278 uint8_t a_idx;
279 char *a_buf;
280#else
281 /* static—̈æ‚̃oƒbƒtƒ@—̈æ */
282 static char a_buf[_ECN_FBS_DBG_BINDMP_BUFLEN];
283#endif
284 const uint8_t *p = buffer; /* “Ç‚ÝŽæ‚èƒ|ƒCƒ“ƒ^ */
285 int i, a_blk, a_blk_max, a_pos = 0;
286 const T_ECN_EDT_HDR *p_req_esv;
287 const T_ECN_INTERNAL_MSG *p_im;
288
289#ifdef SEM_ECN_DBG_BINDMP
290 syscall(wai_sem(SEM_ECN_DBG_BINDMP));
291#endif
292
293 if (len != 256) {
294 a_blk_max = 1;
295 } else {
296 a_blk_max = ((T_ECN_FST_BLK *)buffer)->hdr.wr.blk
297 + (((T_ECN_FST_BLK *)buffer)->hdr.wr.pos ? 1 : 0);
298 if (!a_blk_max)
299 a_blk_max = 1;
300 }
301 #ifndef ECN_DBG_BINDMP_MAXLEN
302 /* bindmpo—͂̍őåƒTƒCƒY */
303 #define ECN_DBG_BINDMP_MAXLEN 1600
304 #endif
305 if (ECN_DBG_BINDMP_MAXLEN < len) {
306 len = ECN_DBG_BINDMP_MAXLEN;
307 }
308
309#ifdef _ECN_FBS_DBG_BINDMP_BUF_MAX_BIT
310 a_idx = (++a_idx_vol) & ((1 << _ECN_FBS_DBG_BINDMP_BUF_MAX_BIT) - 1);
311 a_buf = a_buf_area[a_idx];
312 /* #define a_buf (a_buf_area[a_idx]) */
313#endif
314
315 for (a_blk = 0; p && a_blk < a_blk_max; p = ((T_ECN_FST_BLK *)buffer)->lnk.p_sub[a_blk++]->dat) {
316 if (0 < a_blk) {
317 _ECN_DBG_WAI_SYSLOG; /* syslog()ƒoƒbƒtƒ@‚É—]—T‚ª‚Å‚«‚é‚Ü‚Å‘Ò‚Â */
318 syslog(LOG_NOTICE, "p_sub[%d] (0x%08X)", a_blk - 1, p);
319 }
320 memset(a_buf, 0, _ECN_FBS_DBG_BINDMP_BUFLEN);
321 for (i = 0; i < (int)len; i++) {
322 if (i % 16 == 0) {
323 if (a_buf[0]) {
324 _ECN_DBG_WAI_SYSLOG; /* syslog()ƒoƒbƒtƒ@‚É—]—T‚ª‚Å‚«‚é‚Ü‚Å‘Ò‚Â */
325 syslog(LOG_NOTICE, "%s", a_buf);
326 }
327#ifdef _MSC_VER
328 sprintf_s(a_buf, _ECN_FBS_DBG_BINDMP_BUFLEN, "[%08X]:", i);
329#else
330 sprintf(a_buf, "[%08X]:", i);
331#endif
332 a_pos = strlen(a_buf);
333 } else {
334 a_buf[a_pos++] = (i % 16 == 8 ? '-':' ');
335 }
336#ifdef _MSC_VER
337 sprintf_s(a_buf + a_pos, _ECN_FBS_DBG_BINDMP_BUFLEN - a_pos, "%02X", p[i]);
338#else
339 sprintf(a_buf + a_pos, "%02X", p[i]);
340#endif
341 a_pos += 2;
342 }
343 if (a_buf[0]) {
344 _ECN_DBG_WAI_SYSLOG; /* syslog()ƒoƒbƒtƒ@‚É—]—T‚ª‚Å‚«‚é‚Ü‚Å‘Ò‚Â */
345 syslog(LOG_NOTICE, "%s", a_buf);
346 }
347 if (a_blk_max == 1)
348 break;
349 }
350
351 if (len == 256) {
352 switch (((const T_ECN_FST_BLK *)buffer)->hdr.type) {
353 case ECN_MSG_ECHONET:
354 p_req_esv = &((const T_ECN_FST_BLK *)buffer)->d.t_esv;
355 _ECN_DBG_WAI_SYSLOG; /* syslog()ƒoƒbƒtƒ@‚É—]—T‚ª‚Å‚«‚é‚Ü‚Å‘Ò‚Â */
356 syslog(LOG_NOTICE, " sender: %d %s, target: %d %s",
357 ((T_ECN_FST_BLK *)buffer)->hdr.sender, _ecn_dbg_enod2str(((T_ECN_FST_BLK *)buffer)->hdr.sender),
358 ((T_ECN_FST_BLK *)buffer)->hdr.target, _ecn_dbg_enod2str(((T_ECN_FST_BLK *)buffer)->hdr.target));
359 _ECN_DBG_WAI_SYSLOG; /* syslog()ƒoƒbƒtƒ@‚É—]—T‚ª‚Å‚«‚é‚Ü‚Å‘Ò‚Â */
360 syslog(LOG_NOTICE, " 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);
361 _ECN_DBG_WAI_SYSLOG; /* syslog()ƒoƒbƒtƒ@‚É—]—T‚ª‚Å‚«‚é‚Ü‚Å‘Ò‚Â */
362 syslog(LOG_NOTICE, " edata: 0x%06X 0x%06X 0x%02X 0x%02X (%s)",
363 p_req_esv->edata.seoj.eojx1 << 16 | p_req_esv->edata.seoj.eojx2 << 8 | p_req_esv->edata.seoj.eojx3,
364 p_req_esv->edata.deoj.eojx1 << 16 | p_req_esv->edata.deoj.eojx2 << 8 | p_req_esv->edata.deoj.eojx3,
365 p_req_esv->edata.esv, p_req_esv->edata.opc, _ecn_dbg_esv2str(p_req_esv->edata.esv));
366 _ECN_DBG_WAI_SYSLOG; /* syslog()ƒoƒbƒtƒ@‚É—]—T‚ª‚Å‚«‚é‚Ü‚Å‘Ò‚Â */
367 syslog(LOG_NOTICE, " ecn_prp: 0x%02X 0x%02X", p_req_esv->ecn_prp.epc, p_req_esv->ecn_prp.pdc);
368 _ECN_DBG_WAI_SYSLOG; /* syslog()ƒoƒbƒtƒ@‚É—]—T‚ª‚Å‚«‚é‚Ü‚Å‘Ò‚Â */
369 syslog(LOG_NOTICE, " cur(blk/pos): wr %d/%d, rd %d/%d",
370 (int)((T_ECN_FST_BLK *)buffer)->hdr.wr.blk,
371 (int)((T_ECN_FST_BLK *)buffer)->hdr.wr.pos,
372 (int)((T_ECN_FST_BLK *)buffer)->hdr.rd.blk,
373 (int)((T_ECN_FST_BLK *)buffer)->hdr.rd.pos);
374 break;
375 case ECN_MSG_INTERNAL:
376 p_im = (const T_ECN_INTERNAL_MSG *)&((const T_ECN_FST_BLK *)buffer)->payload[0];
377 syslog(LOG_NOTICE, " a_im.command: %d:%s", p_im->command,
378 (p_im->command == ECN_INM_NOTIFY_INSTANCELIST ? "ECN_INM_NOTIFY_INSTANCELIST":
379 (p_im->command == ECN_INM_RELEASE_WAIT ? "ECN_INM_RELEASE_WAIT" : "?")));
380 memset(a_buf, 0, _ECN_FBS_DBG_BINDMP_BUFLEN);
381 a_blk_max = ((const T_ECN_FST_BLK *)buffer)->hdr.wr.blk * 64
382 + ((const T_ECN_FST_BLK *)buffer)->hdr.wr.pos;
383 if (0 < a_blk_max) {
384 if (64 < a_blk_max)
385 a_blk_max = 64;
386 if (_ECN_FBS_DBG_BINDMP_BUFLEN < a_blk_max)
387 a_blk_max = _ECN_FBS_DBG_BINDMP_BUFLEN;
388 for (i = offsetof(T_ECN_INTERNAL_MSG, data); i < a_blk_max; i++) {
389 a_blk = ((const T_ECN_FST_BLK *)buffer)->payload[i];
390 if (!isprint(a_blk) || !isascii(a_blk))
391 a_blk = '.';
392 a_buf[i - 1] = a_blk;
393 }
394 syslog(LOG_NOTICE, " a_im.data: [%s]", &a_buf[offsetof(T_ECN_INTERNAL_MSG, data) - 1]);
395 }
396 break;
397 default:
398 syslog(LOG_NOTICE, " invalid type: %d", ((const T_ECN_FST_BLK *)buffer)->hdr.type);
399 }
400 }
401 else if (8 <= len
402 && ((const T_ECN_FST_BLK *)buffer)->bin[0] == 0x10
403 && ((const T_ECN_FST_BLK *)buffer)->bin[1] == 0x81) {
404 p_req_esv = (const T_ECN_EDT_HDR *)&((const T_ECN_FST_BLK *)buffer)->bin[0];
405 _ECN_DBG_WAI_SYSLOG; /* syslog()ƒoƒbƒtƒ@‚É—]—T‚ª‚Å‚«‚é‚Ü‚Å‘Ò‚Â */
406 syslog(LOG_NOTICE, " 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);
407 _ECN_DBG_WAI_SYSLOG; /* syslog()ƒoƒbƒtƒ@‚É—]—T‚ª‚Å‚«‚é‚Ü‚Å‘Ò‚Â */
408 syslog(LOG_NOTICE, " edata: 0x%06X 0x%06X 0x%02X 0x%02X (%s)",
409 p_req_esv->edata.seoj.eojx1 << 16 | p_req_esv->edata.seoj.eojx2 << 8 | p_req_esv->edata.seoj.eojx3,
410 p_req_esv->edata.deoj.eojx1 << 16 | p_req_esv->edata.deoj.eojx2 << 8 | p_req_esv->edata.deoj.eojx3,
411 p_req_esv->edata.esv, p_req_esv->edata.opc, _ecn_dbg_esv2str(p_req_esv->edata.esv));
412 _ECN_DBG_WAI_SYSLOG; /* syslog()ƒoƒbƒtƒ@‚É—]—T‚ª‚Å‚«‚é‚Ü‚Å‘Ò‚Â */
413 syslog(LOG_NOTICE, " ecn_prp: 0x%02X 0x%02X", p_req_esv->ecn_prp.epc, p_req_esv->ecn_prp.pdc);
414 }
415#ifdef SEM_ECN_DBG_BINDMP
416 syscall(sig_sem(SEM_ECN_DBG_BINDMP));
417#endif
418}
419
420/*
421 * ECHONET LiteƒT[ƒrƒXƒR[ƒh•¶Žš—ñ•ÏŠ·
422 */
423const char *_ecn_dbg_esv2str(uint8_t fa_esv)
424{
425 switch (fa_esv) {
426 case ESV_SET_I_SNA: return "ƒvƒƒpƒeƒB’l‘‚«ž‚Ý—v‹•s‰Â‰ž“š"; /* 0x50 */
427 case ESV_SET_C_SNA: return "ƒvƒƒpƒeƒB’l‘‚«ž‚Ý—v‹•s‰Â‰ž“š"; /* 0x51 */
428 case ESV_GET_SNA: return "ƒvƒƒpƒeƒB’l“ǂݏo‚µ•s‰Â‰ž“š"; /* 0x52 */
429 case ESV_INF_SNA: return "ƒvƒƒpƒeƒB’l’Ê’m•s‰Â‰ž“š"; /* 0x53 */
430 case ESV_SET_GET_SNA: return "ƒvƒƒpƒeƒB’l‘‚«ž‚݁E“ǂݏo‚µ•s‰Â‰ž“š"; /* 0x5E */
431 case ESV_SET_I: return "ƒvƒƒpƒeƒB’l‘‚«ž‚Ý—v‹i‰ž“š•s—vj"; /* 0x60 */
432 case ESV_SET_C: return "ƒvƒƒpƒeƒB’l‘‚«ž‚Ý—v‹i‰ž“š—vj"; /* 0x61 */
433 case ESV_GET: return "ƒvƒƒpƒeƒB’l“ǂݏo‚µ—v‹"; /* 0x62 */
434 case ESV_INF_REQ: return "ƒvƒƒpƒeƒB’l’Ê’m—v‹"; /* 0x63 */
435 case ESV_SET_GET: return "ƒvƒƒpƒeƒB’l‘‚«ž‚݁E“ǂݏo‚µ—v‹"; /* 0x6E */
436 case ESV_SET_RES: return "ƒvƒƒpƒeƒB’l‘‚«ž‚݉ž“š"; /* 0x71 */
437 case ESV_GET_RES: return "ƒvƒƒpƒeƒB’l“ǂݏo‚µ‰ž“š"; /* 0x72 */
438 case ESV_INF: return "ƒvƒƒpƒeƒB’l’Ê’m"; /* 0x73 */
439 case ESV_INFC: return "ƒvƒƒpƒeƒB’l’Ê’mi‰ž“š—vj"; /* 0x74 */
440 case ESV_SET_GET_RES: return "ƒvƒƒpƒeƒB’l‘‚«ž‚݁E“ǂݏo‚µ‰ž“š"; /* 0x7E */
441 case ESV_INFC_RES: return "ƒvƒƒpƒeƒB’l’Ê’m‰ž“š"; /* 0x7A */
442 default:
443 return "(unknown)";
444 }
445}
446#endif /* #if defined(ECN_DBG_PUT_ENA) || defined(ECN_CAP_PUT_ENA) */
Note: See TracBrowser for help on using the repository browser.