Changeset 364 for asp3_tinet_ecnl_arm/trunk/ntshell
- Timestamp:
- Feb 1, 2019, 9:57:09 PM (5 years ago)
- Location:
- asp3_tinet_ecnl_arm/trunk/ntshell
- Files:
-
- 4 added
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet.c
r352 r364 56 56 57 57 /* 58 * インスタンスリスト通知の送信 59 */ 60 ER ecn_ntf_inl() 61 { 62 return _ecn_tsk_ntf_inl(); 63 } 64 65 /* 58 66 * ECHONETオブジェクト参照 59 67 * 引数 … … 393 401 return E_PAR; 394 402 395 a_ret = trcv_dtq(ecn_api_ mailboxid, (intptr_t *)&p_msg, fa_tmout);403 a_ret = trcv_dtq(ecn_api_dataqueueid, (intptr_t *)&p_msg, fa_tmout); 396 404 if (a_ret != E_OK) { 397 405 *ppk_esv = NULL; … … 425 433 a_ret = _ecn_fbs_del(a_fbs); 426 434 return a_ret; 435 } 436 437 /* 438 * 応答電文の送信元ノードを取得する 439 */ 440 ID ecn_get_enod(T_EDATA *pk_esv) 441 { 442 const EOBJCB *p_snod; 443 const EOBJINIB *p_sobj = NULL; 444 445 p_snod = _ecn_eno_fnd(((T_ECN_FST_BLK *)pk_esv)->hdr.sender.id); 446 if (p_snod != NULL) { 447 p_sobj = p_snod->profile; 448 } 449 450 if (p_sobj == NULL) 451 return EOBJ_NULL; 452 #ifdef ECHONET_CONTROLLER_EXTENTION 453 if (p_sobj->eprpcnt == 0) 454 return ecn_agent_get_eobj(p_sobj); 455 #endif 456 return 1 + (((intptr_t)p_sobj - (intptr_t)eobjinib_table) / sizeof(EOBJINIB)); 427 457 } 428 458 -
asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet.h
r352 r364 67 67 typedef enum _echonet_enod_id 68 68 { 69 ENOD_NOT_MATCH_ID = -1, 69 ENOD_NOT_MATCH_ID = -1, /* アドレスID登録なし */ 70 70 ENOD_MULTICAST_ID = 0, /* マルチキャストアドレスID */ 71 71 ENOD_LOCAL_ID = 1, /* 自ノードアドレスID */ … … 279 279 extern const ID ecn_svc_taskid; 280 280 extern const ID ecn_udp_taskid; 281 extern const ID ecn_api_ mailboxid;282 extern const ID ecn_svc_ mailboxid;283 extern const ID ecn_udp_ mailboxid;281 extern const ID ecn_api_dataqueueid; 282 extern const ID ecn_svc_dataqueueid; 283 extern const ID ecn_udp_dataqueueid; 284 284 #ifndef ECHONET_USE_MALLOC 285 285 extern const ID ecn_mempoolid; … … 309 309 310 310 /* 311 * インスタンスリスト通知の送信 312 */ 313 ER ecn_ntf_inl(); 314 315 /* 311 316 * ECHONETオブジェクト参照 312 317 */ … … 392 397 */ 393 398 ER ecn_rel_esv(T_EDATA *pk_esv); 399 400 /* 401 * 応答電文の送信元ノードを取得する 402 */ 403 ID ecn_get_enod(T_EDATA *pk_esv); 394 404 395 405 /* -
asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet.trb
r352 r364 634 634 const ID _echonet_ecn_svc_taskid = ECHONET_SVC_TASK; 635 635 const ID _echonet_ecn_udp_taskid = ECHONET_UDP_TASK; 636 const ID _echonet_ecn_api_ mailboxid = ECHONET_API_MAILBOX;637 const ID _echonet_ecn_svc_ mailboxid = ECHONET_SVC_MAILBOX;638 const ID _echonet_ecn_udp_ mailboxid = ECHONET_UDP_MAILBOX;636 const ID _echonet_ecn_api_dataqueueid = ECHONET_API_DATAQUEUE; 637 const ID _echonet_ecn_svc_dataqueueid = ECHONET_SVC_DATAQUEUE; 638 const ID _echonet_ecn_udp_dataqueueid = ECHONET_UDP_DATAQUEUE; 639 639 #ifndef ECHONET_USE_MALLOC 640 640 const ID _echonet_ecn_mempoolid = ECHONET_MEMPOOL; -
asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet_asp.cfg
r352 r364 51 51 52 52 /* 53 * ECHONET Lite API用 メールボックス53 * ECHONET Lite API用データキュー 54 54 */ 55 CRE_DTQ(ECHONET_API_ MAILBOX, { TA_TFIFO, 1, NULL });55 CRE_DTQ(ECHONET_API_DATAQUEUE, { TA_TFIFO, ECHONET_API_DATAQUEUE_COUNT, NULL }); 56 56 57 57 /* 58 * ECHONET Lite サービス処理タスク用 メールボックス58 * ECHONET Lite サービス処理タスク用データキュー 59 59 */ 60 CRE_DTQ(ECHONET_SVC_ MAILBOX, { TA_TFIFO, 1, NULL });60 CRE_DTQ(ECHONET_SVC_DATAQUEUE, { TA_TFIFO, ECHONET_SVC_DATAQUEUE_COUNT, NULL }); 61 61 62 62 /* … … 66 66 67 67 /* 68 * ECHONET Lite UDP通信処理用 メールボックス68 * ECHONET Lite UDP通信処理用データキュー 69 69 */ 70 CRE_DTQ(ECHONET_UDP_ MAILBOX, { TA_TFIFO, 1, NULL });70 CRE_DTQ(ECHONET_UDP_DATAQUEUE, { TA_TFIFO, ECHONET_UDP_DATAQUEUE_COUNT, NULL }); 71 71 72 72 /* -
asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet_rename.h
r352 r364 47 47 #define ecn_svc_taskid _echonet_ecn_svc_taskid 48 48 #define ecn_udp_taskid _echonet_ecn_udp_taskid 49 #define ecn_api_ mailboxid _echonet_ecn_api_mailboxid50 #define ecn_svc_ mailboxid _echonet_ecn_svc_mailboxid51 #define ecn_udp_ mailboxid _echonet_ecn_udp_mailboxid49 #define ecn_api_dataqueueid _echonet_ecn_api_dataqueueid 50 #define ecn_svc_dataqueueid _echonet_ecn_svc_dataqueueid 51 #define ecn_udp_dataqueueid _echonet_ecn_udp_dataqueueid 52 52 #define ecn_mempoolid _echonet_ecn_mempoolid 53 53 #define ecn_udp_cepid _echonet_ecn_udp_cepid -
asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet_task.c
r352 r364 77 77 static bool_t g_release_esv; 78 78 79 ER _ecn_tsk_ntf_inl(intptr_t fa_exinf);80 81 79 ER _ecn_tsk_snd_dtq(ECN_FBS_ID fa_rsp_fbs, bool_t from_app) 82 80 { 83 81 ER a_ret; 84 82 T_MSG *msg = (T_MSG *)fa_rsp_fbs.ptr; 85 ID dtqid = ecn_udp_ mailboxid;83 ID dtqid = ecn_udp_dataqueueid; 86 84 int i; 87 85 #ifdef ECN_DBG_PUT_ENA … … 90 88 if (from_app && (((T_EDATA *)fa_rsp_fbs.ptr)->hdr.edata.esv == ESV_INFC)) { 91 89 g_api_tid = ((T_EDATA *)fa_rsp_fbs.ptr)->hdr.ecn_hdr.tid; 92 dtqid = ecn_svc_ mailboxid;90 dtqid = ecn_svc_dataqueueid; 93 91 } 94 92 else { … … 98 96 g_api_tid = ((T_EDATA *)fa_rsp_fbs.ptr)->hdr.ecn_hdr.tid; 99 97 100 dtqid = ecn_udp_ mailboxid;98 dtqid = ecn_udp_dataqueueid; 101 99 break; 102 100 case ENOD_LOCAL_ID: 103 101 if (from_app) 104 dtqid = ecn_svc_ mailboxid;102 dtqid = ecn_svc_dataqueueid; 105 103 else 106 dtqid = ecn_api_ mailboxid;104 dtqid = ecn_api_dataqueueid; 107 105 break; 108 106 case ENOD_API_ID: 109 dtqid = ecn_api_ mailboxid;107 dtqid = ecn_api_dataqueueid; 110 108 break; 111 109 default: … … 121 119 switch (eobjcb_table[i].profile->eobjatr) { 122 120 case EOBJ_SYNC_REMOTE_NODE: 123 dtqid = ecn_udp_ mailboxid;121 dtqid = ecn_udp_dataqueueid; 124 122 break; 125 123 case EOBJ_ASYNC_REMOTE_NODE: 126 dtqid = ecn_svc_ mailboxid;124 dtqid = ecn_svc_dataqueueid; 127 125 break; 128 126 default: … … 131 129 } 132 130 else { 133 dtqid = ecn_udp_ mailboxid;131 dtqid = ecn_udp_dataqueueid; 134 132 } 135 133 break; … … 242 240 #endif 243 241 244 a_ret = trcv_dtq(ecn_svc_ mailboxid, (intptr_t *)&a_mdt.p_msg, a_timer);242 a_ret = trcv_dtq(ecn_svc_dataqueueid, (intptr_t *)&a_mdt.p_msg, a_timer); 245 243 if ((a_ret != E_OK) && (a_ret != E_TMOUT)) { 246 244 ECN_DBG_PUT_2("trcv_dtq() result = %d:%s", a_ret, itron_strerror(a_ret)); … … 867 865 g_release_esv = false; 868 866 869 ECN_CAP_PUT_1("redirect ecn_svc_ mailboxid → ecn_api_mailboxid (esv:0x%02X)",867 ECN_CAP_PUT_1("redirect ecn_svc_dataqueueid → ecn_api_dataqueueid (esv:0x%02X)", 870 868 p_esv->edata.esv); 871 869 fa_fbs_id.ptr->hdr.target.id = ENOD_API_ID; 872 a_ret = snd_dtq(ecn_api_ mailboxid, (intptr_t)fa_fbs_id.ptr);870 a_ret = snd_dtq(ecn_api_dataqueueid, (intptr_t)fa_fbs_id.ptr); 873 871 if (a_ret != E_OK) { 874 872 syslog(LOG_WARNING, "_ecn_tsk_ecn_msg() : snd_dtq() result = %d:%s", a_ret, itron_strerror(a_ret)); … … 2024 2022 req.ptr->hdr.type = ECN_MSG_INTERNAL; 2025 2023 req.ptr->hdr.sender.dtqid = sender; 2026 req.ptr->hdr.target.dtqid = ecn_svc_ mailboxid;2024 req.ptr->hdr.target.dtqid = ecn_svc_dataqueueid; 2027 2025 req.ptr->hdr.reply.dtqid = sender; 2028 2026 … … 2052 2050 2053 2051 res.ptr->hdr.type = ECN_MSG_INTERNAL; 2054 res.ptr->hdr.sender.dtqid = ecn_svc_ mailboxid;2052 res.ptr->hdr.sender.dtqid = ecn_svc_dataqueueid; 2055 2053 res.ptr->hdr.target.dtqid = req.ptr->hdr.reply.dtqid; 2056 res.ptr->hdr.reply.dtqid = ecn_svc_ mailboxid;2054 res.ptr->hdr.reply.dtqid = ecn_svc_dataqueueid; 2057 2055 2058 2056 *pk_res = res; -
asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet_task.h
r352 r364 110 110 } T_ECN_INTERNAL_MSG; 111 111 112 /* 113 * インスタンスリスト通知の送信 114 */ 115 ER _ecn_tsk_ntf_inl(); 112 116 /* 113 117 * 要求電文作成 -
asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet_udp6_task.c
r352 r364 151 151 152 152 /* echonet_taskに送る */ 153 a_ret = snd_dtq(ecn_svc_ mailboxid, (intptr_t)a_fbs_id.ptr);154 if (a_ret != E_OK) { 155 ECN_DBG_PUT_2("[UDP ECHO SRV] snd_dtq(ecn_svc_ mailboxid) result = %d:%s", a_ret, itron_strerror(a_ret));153 a_ret = snd_dtq(ecn_svc_dataqueueid, (intptr_t)a_fbs_id.ptr); 154 if (a_ret != E_OK) { 155 ECN_DBG_PUT_2("[UDP ECHO SRV] snd_dtq(ecn_svc_dataqueueid) result = %d:%s", a_ret, itron_strerror(a_ret)); 156 156 goto lb_except; 157 157 } … … 201 201 a_timer = ECHONET_UDP_TASK_GET_TIMER; 202 202 203 a_ret = trcv_dtq(ecn_udp_ mailboxid, (intptr_t *)&a_mdt.p_msg, a_timer);203 a_ret = trcv_dtq(ecn_udp_dataqueueid, (intptr_t *)&a_mdt.p_msg, a_timer); 204 204 if ((a_ret != E_OK) && (a_ret != E_TMOUT)) { 205 205 ECN_DBG_PUT_2("trcv_dtq() result = %d:%s", a_ret, itron_strerror(a_ret)); … … 261 261 req.ptr->hdr.type = ECN_MSG_INTERNAL; 262 262 req.ptr->hdr.sender.dtqid = sender; 263 req.ptr->hdr.target.dtqid = ecn_udp_ mailboxid;263 req.ptr->hdr.target.dtqid = ecn_udp_dataqueueid; 264 264 req.ptr->hdr.reply.dtqid = sender; 265 265 … … 289 289 290 290 res.ptr->hdr.type = ECN_MSG_INTERNAL; 291 res.ptr->hdr.sender.dtqid = ecn_udp_ mailboxid;291 res.ptr->hdr.sender.dtqid = ecn_udp_dataqueueid; 292 292 res.ptr->hdr.target.dtqid = req.ptr->hdr.reply.dtqid; 293 res.ptr->hdr.reply.dtqid = ecn_udp_ mailboxid;293 res.ptr->hdr.reply.dtqid = ecn_udp_dataqueueid; 294 294 295 295 *pk_res = res; … … 416 416 else if (memcmp(&a_dst.ipaddr, &locl, sizeof(a_dst.ipaddr)) == 0) { 417 417 /* 送信先が127.0.0.1 → dtqに転送 */ 418 ECN_DBG_PUT_1("redirect ecn_udp_ mailboxid → ecn_svc_mailboxid (esv:0x%02X)",418 ECN_DBG_PUT_1("redirect ecn_udp_dataqueueid → ecn_svc_dataqueueid (esv:0x%02X)", 419 419 ((T_EDATA *)fbs_id.ptr)->hdr.edata.esv); 420 420 … … 462 462 463 463 switch (fncd) { 464 case T FN_UDP_CRE_CEP:464 case TEV_UDP_RCV_DAT: 465 465 case TFN_UDP_RCV_DAT: 466 466 /* ECN_CAP_PUT("[UDP ECHO SRV] callback_nblk_udp() recv: %u", *(int *)p_parblk); */ … … 488 488 return E_OK; 489 489 490 case TFN_UDP_CRE_CEP: 490 491 case TFN_UDP_SND_DAT: 491 492 break; 492 493 default: 493 494 ECN_CAP_PUT_2("[UDP ECHO SRV] fncd:0x%04X(%s)", -fncd, 495 (fncd == TEV_UDP_RCV_DAT ? "TEV_UDP_RCV_DAT" : 494 496 (fncd == TFN_UDP_CRE_CEP ? "TFN_UDP_CRE_CEP" : 495 497 (fncd == TFN_UDP_RCV_DAT ? "TFN_UDP_RCV_DAT" : 496 (fncd == TFN_UDP_SND_DAT ? "TFN_UDP_SND_DAT" : "undef")))) ;498 (fncd == TFN_UDP_SND_DAT ? "TFN_UDP_SND_DAT" : "undef"))))); 497 499 498 500 error = E_PAR; -
asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet_udp6_task.h
r352 r364 71 71 #endif /* ECHONET_UDP_TASK_STACK_SIZE */ 72 72 73 #ifndef NUM_ECHONET_UDP_ MAILBOX74 #define NUM_ECHONET_UDP_ MAILBOX1075 #endif /* NUM_ECHONET_UDP_ MAILBOX*/73 #ifndef NUM_ECHONET_UDP_DATAQUEUE 74 #define NUM_ECHONET_UDP_DATAQUEUE 10 75 #endif /* NUM_ECHONET_UDP_DATAQUEUE */ 76 76 77 77 /* -
asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet_udp_task.c
r352 r364 146 146 147 147 /* echonet_taskに送る */ 148 a_ret = snd_dtq(ecn_svc_ mailboxid, (intptr_t)a_fbs_id.ptr);149 if (a_ret != E_OK) { 150 ECN_DBG_PUT_2("[UDP ECHO SRV] snd_dtq(ecn_svc_ mailboxid) result = %d:%s", a_ret, itron_strerror(a_ret));148 a_ret = snd_dtq(ecn_svc_dataqueueid, (intptr_t)a_fbs_id.ptr); 149 if (a_ret != E_OK) { 150 ECN_DBG_PUT_2("[UDP ECHO SRV] snd_dtq(ecn_svc_dataqueueid) result = %d:%s", a_ret, itron_strerror(a_ret)); 151 151 goto lb_except; 152 152 } … … 206 206 a_timer = ECHONET_UDP_TASK_GET_TIMER; 207 207 208 a_ret = trcv_dtq(ecn_udp_ mailboxid, (intptr_t *)&a_mdt.p_msg, a_timer);208 a_ret = trcv_dtq(ecn_udp_dataqueueid, (intptr_t *)&a_mdt.p_msg, a_timer); 209 209 if ((a_ret != E_OK) && (a_ret != E_TMOUT)) { 210 210 ECN_DBG_PUT_2("trcv_dtq() result = %d:%s", a_ret, itron_strerror(a_ret)); … … 266 266 req.ptr->hdr.type = ECN_MSG_INTERNAL; 267 267 req.ptr->hdr.sender.dtqid = sender; 268 req.ptr->hdr.target.dtqid = ecn_udp_ mailboxid;268 req.ptr->hdr.target.dtqid = ecn_udp_dataqueueid; 269 269 req.ptr->hdr.reply.dtqid = sender; 270 270 … … 294 294 295 295 res.ptr->hdr.type = ECN_MSG_INTERNAL; 296 res.ptr->hdr.sender.dtqid = ecn_udp_ mailboxid;296 res.ptr->hdr.sender.dtqid = ecn_udp_dataqueueid; 297 297 res.ptr->hdr.target.dtqid = req.ptr->hdr.reply.dtqid; 298 res.ptr->hdr.reply.dtqid = ecn_udp_ mailboxid;298 res.ptr->hdr.reply.dtqid = ecn_udp_dataqueueid; 299 299 300 300 *pk_res = res; … … 420 420 else if (a_dst.ipaddr == MAKE_IPV4_ADDR(127,0,0,1)) { 421 421 /* 送信先が127.0.0.1 → dtqに転送 */ 422 ECN_DBG_PUT_1("redirect ecn_udp_ mailboxid → ecn_svc_mailboxid (esv:0x%02X)",422 ECN_DBG_PUT_1("redirect ecn_udp_dataqueueid → ecn_svc_dataqueueid (esv:0x%02X)", 423 423 ((T_EDATA *)fbs_id.ptr)->hdr.edata.esv); 424 424 … … 466 466 467 467 switch (fncd) { 468 case T FN_UDP_CRE_CEP:468 case TEV_UDP_RCV_DAT: 469 469 case TFN_UDP_RCV_DAT: 470 470 /* ECN_CAP_PUT("[UDP ECHO SRV] callback_nblk_udp() recv: %u", *(int *)p_parblk); */ … … 492 492 return E_OK; 493 493 494 case TFN_UDP_CRE_CEP: 494 495 case TFN_UDP_SND_DAT: 495 496 break; 496 497 default: 497 498 ECN_CAP_PUT_2("[UDP ECHO SRV] fncd:0x%04X(%s)", -fncd, 499 (fncd == TEV_UDP_RCV_DAT ? "TEV_UDP_RCV_DAT" : 498 500 (fncd == TFN_UDP_CRE_CEP ? "TFN_UDP_CRE_CEP" : 499 501 (fncd == TFN_UDP_RCV_DAT ? "TFN_UDP_RCV_DAT" : 500 (fncd == TFN_UDP_SND_DAT ? "TFN_UDP_SND_DAT" : "undef")))) ;502 (fncd == TFN_UDP_SND_DAT ? "TFN_UDP_SND_DAT" : "undef"))))); 501 503 502 504 error = E_PAR; -
asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet_udp_task.h
r352 r364 71 71 #endif /* ECHONET_UDP_TASK_STACK_SIZE */ 72 72 73 #ifndef NUM_ECHONET_UDP_ MAILBOX74 #define NUM_ECHONET_UDP_ MAILBOX1075 #endif /* NUM_ECHONET_UDP_ MAILBOX*/73 #ifndef NUM_ECHONET_UDP_DATAQUEUE 74 #define NUM_ECHONET_UDP_DATAQUEUE 10 75 #endif /* NUM_ECHONET_UDP_DATAQUEUE */ 76 76 77 77 /* -
asp3_tinet_ecnl_arm/trunk/ntshell/fatfs/ffarch.h
r359 r364 41 41 #define FFARCH_STACK_SIZE 512 42 42 43 void ffarch_init( );43 void ffarch_init(void); 44 44 void ffarch_task(intptr_t exinf); 45 int ffarch_get_timer( );45 int ffarch_get_timer(void); 46 46 void ffarch_progress(int elapse); 47 void ffarch_timeout( );47 void ffarch_timeout(void); 48 48 49 49 void sdfs_cychdr(intptr_t exinf); -
asp3_tinet_ecnl_arm/trunk/ntshell/lcd/draw_font.c
r352 r364 1 1 /* 2 2 * TOPPERS ECHONET Lite Communication Middleware 3 * 3 * 4 4 * Copyright (C) 2018 Cores Co., Ltd. Japan 5 * 5 * 6 6 * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 7 7 * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 … … 26 26 * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 27 27 * 免責すること. 28 * 28 * 29 29 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 30 30 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 … … 32 32 * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 33 33 * の責任を負わない. 34 * 34 * 35 35 * @(#) $Id$ 36 36 */ … … 41 41 #include <string.h> 42 42 #include <target_syssvc.h> 43 #ifndef ADAFRUIT_SSD1306 43 44 #include "adafruit_st7735.h" 45 #else 46 #include "adafruit_ssd1306.h" 47 #endif 44 48 #include "draw_font.h" 45 #include "misaki_font.h" 46 47 void get_bitmap_font(char *string, unsigned char *bitmap_data, unsigned long *use_chars) 48 { 49 unsigned long len, code; 50 unsigned char i,j,k; 51 unsigned long totalj, totalk; 49 50 void get_bitmap_font(const uint8_t *string, uint8_t *bitmap_data, uint32_t *use_chars) 51 { 52 uint32_t len, code; 53 uint8_t i, j, k; 54 uint32_t totalj, totalk; 52 55 53 56 *use_chars = 0; 54 57 len = 0; 55 if ((string[0] & 0x80) ==0) { len = 1; }58 if ((string[0] & 0x80) == 0) { len = 1; } 56 59 else if ((string[0] & 0xE0) == 0xC0) { len = 2; } 57 60 else if ((string[0] & 0xF0) == 0xE0) { len = 3; } 58 61 else if ((string[0] & 0xF8) == 0xF0) { len = 4; } 59 else { return; 62 else { return; } 60 63 61 64 j = k = totalj = totalk = 0; 62 65 63 if ( len == 1) {66 if (len == 1) { 64 67 code = string[0]; 65 memcpy(bitmap_data, &UTF8_1B_CODE_BITMAP[code][0], 8);68 memcpy(bitmap_data, &UTF8_1B_CODE_BITMAP[code][0], FONT_WIDTH * FONT_HEIGHT / 8); 66 69 *use_chars = 1; 67 70 return; 68 71 } 69 72 70 if ( len == 2) {73 if (len == 2) { 71 74 code = string[0]; 72 75 // 1バイト目サーチ 73 for (i = 0; i < UTF8_CODE_2B_1_NUM; i++) {74 if ( Utf8CodeTable_2B_1st[i][0] == code) {76 for (i = 0; i < UTF8_CODE_2B_1_NUM; i++) { 77 if (Utf8CodeTable_2B_1st[i][0] == code) { 75 78 code = string[1]; 76 for ( j = 0; j < Utf8CodeTable_2B_1st[i][1]; j++) {77 if ( UTF8_2B_CODE_BITMAP[totalk].code == code) {78 memcpy(bitmap_data, UTF8_2B_CODE_BITMAP[totalk].bitmap, 8);79 for (j = 0; j < Utf8CodeTable_2B_1st[i][1]; j++) { 80 if (UTF8_2B_CODE_BITMAP[totalk].code == code) { 81 memcpy(bitmap_data, UTF8_2B_CODE_BITMAP[totalk].bitmap, FONT_WIDTH * FONT_HEIGHT / 8); 79 82 *use_chars = 2; 80 83 return; … … 90 93 } 91 94 92 if ( len == 3) {95 if (len == 3) { 93 96 code = string[0]; 94 97 // 1バイト目サーチ 95 for (i = 0; i < UTF8_CODE_3B_1_NUM; i++) {96 if ( Utf8CodeTable_3B_1st[i][0] == code) {98 for (i = 0; i < UTF8_CODE_3B_1_NUM; i++) { 99 if (Utf8CodeTable_3B_1st[i][0] == code) { 97 100 code = string[1]; 98 101 // 2バイト目サーチ 99 for ( j = 0; j < Utf8CodeTable_3B_1st[i][1]; j++ ){100 if ( Utf8CodeTable_3B_2nd[totalj][0] == code) {102 for (j = 0; j < Utf8CodeTable_3B_1st[i][1]; j++) { 103 if (Utf8CodeTable_3B_2nd[totalj][0] == code) { 101 104 code = string[2]; 102 105 // 3バイト目サーチ 103 for (k = 0; k < Utf8CodeTable_3B_2nd[totalj][1]; k++) {106 for (k = 0; k < Utf8CodeTable_3B_2nd[totalj][1]; k++) { 104 107 if (UTF8_3B_CODE_BITMAP[totalk].code == code) { 105 memcpy(bitmap_data, UTF8_3B_CODE_BITMAP[totalk].bitmap, 8);108 memcpy(bitmap_data, UTF8_3B_CODE_BITMAP[totalk].bitmap, FONT_WIDTH * FONT_HEIGHT / 8); 106 109 *use_chars = 3; 107 110 return; … … 111 114 return; 112 115 } 113 else {/*読み飛ばすbitmap個数を蓄積*/116 else {/*読み飛ばすbitmap個数を蓄積*/ 114 117 totalk += Utf8CodeTable_3B_2nd[totalj][1]; 115 118 } … … 118 121 } 119 122 else {/*読み飛ばすbitmap個数を蓄積*/ 120 for ( j = 0; j < Utf8CodeTable_3B_1st[i][1]; j++) {123 for (j = 0; j < Utf8CodeTable_3B_1st[i][1]; j++) { 121 124 totalk += Utf8CodeTable_3B_2nd[totalj][1]; 122 125 totalj++; … … 128 131 } 129 132 130 void lcd_drawFont(LCD_Handler_t *hlcd, unsigned char *bitmap_data, int x, int y, unsigned short color, unsigned short back_color) 131 { 132 int i, j; 133 134 for(i = 0; i < 8; i++ ) { 135 for(j = 0; j < 8; j++ ) { 136 if (((bitmap_data[i] >> j) & 0x01) == 1){ 137 lcd_drawPixel(hlcd, x - j, y + i, color); 133 void lcd_drawFont(LCD_Handler_t *hlcd, uint8_t *bitmap_data, int x, int y, uint16_t color, uint16_t back_color) 134 { 135 int i, j, b; 136 uint8_t *bitmap = bitmap_data; 137 138 b = 0x80; 139 for (i = 0; i < FONT_HEIGHT; i++) { 140 for (j = 0; j < FONT_WIDTH; j++) { 141 if ((*bitmap & b) != 0) { 142 lcd_drawPixel(hlcd, x + j, y + i, color); 138 143 } 139 144 else { 140 lcd_drawPixel(hlcd, x - j, y + i, back_color); 141 } 142 } 143 } 144 } 145 146 void lcd_drawFontHalf(LCD_Handler_t *hlcd, unsigned char *bitmap_data, int x, int y, unsigned short color, unsigned short back_color) 147 { 148 int i, j; 149 150 for(i = 0; i < 8; i++ ) { 151 for(j = 4; j < 8; j++ ) { 152 if (((bitmap_data[i] >> j) & 0x01) == 1){ 153 lcd_drawPixel(hlcd, x - j, y + i, color); 145 lcd_drawPixel(hlcd, x + j, y + i, back_color); 146 } 147 b >>= 1; 148 if (b == 0) { 149 b = 0x80; 150 bitmap++; 151 } 152 } 153 } 154 } 155 156 void lcd_drawFontHalf(LCD_Handler_t *hlcd, uint8_t *bitmap_data, int x, int y, uint16_t color, uint16_t back_color) 157 { 158 int i, j, b; 159 uint8_t *bitmap = bitmap_data; 160 161 b = 0x80; 162 for (i = 0; i < FONT_HEIGHT; i++) { 163 for (j = 0; j < FONT_HALF_WIDTH; j++) { 164 if ((*bitmap & b) != 0) { 165 lcd_drawPixel(hlcd, x + j, y + i, color); 154 166 } 155 167 else { 156 lcd_drawPixel(hlcd, x - j, y + i, back_color); 157 } 158 } 159 } 160 } 161 162 void lcd_drawString(LCD_Handler_t *hlcd, char *string, int x, int y, unsigned short color, unsigned short back_color ) 163 { 164 unsigned long current_top, use_chars, for_3B_hankaku_code; 165 unsigned char bitmap_data[8], ctrl_code; 166 int local_x, local_y; 168 lcd_drawPixel(hlcd, x + j, y + i, back_color); 169 } 170 b >>= 1; 171 if (b == 0) { 172 b = 0x80; 173 bitmap++; 174 } 175 } 176 } 177 } 178 179 void lcd_drawString(LCD_Handler_t *hlcd, const char *string, int x, int y, uint16_t color, uint16_t back_color) 180 { 181 uint32_t current_top, use_chars, for_3B_hankaku_code; 182 uint8_t bitmap_data[FONT_WIDTH * FONT_HEIGHT / 8], ctrl_code; 183 int local_x, local_y, len = strlen(string); 184 const uint8_t *code = (const uint8_t *)string; 167 185 168 186 local_x = x; … … 170 188 171 189 current_top = 0; 172 while( current_top < strlen(string) ) 173 { 174 memset(bitmap_data,0x0,8); 175 ctrl_code = string[current_top]; 176 get_bitmap_font(&string[current_top], bitmap_data, &use_chars); 177 if(use_chars == 0) 190 while (current_top < len) { 191 memset(bitmap_data, 0x0, FONT_WIDTH * FONT_HEIGHT / 8); 192 ctrl_code = code[current_top]; 193 get_bitmap_font(&code[current_top], bitmap_data, &use_chars); 194 if (use_chars == 0) 178 195 return; 179 196 180 197 //3バイトコード半角文字用 181 if (use_chars == 3) {198 if (use_chars == 3) { 182 199 for_3B_hankaku_code = 0; 183 for_3B_hankaku_code = ( (string[current_top]<< 16) |184 (string[current_top+1] <<8) |185 (string[current_top+2] ));200 for_3B_hankaku_code = ((code[current_top] << 16) | 201 (code[current_top + 1] << 8) | 202 (code[current_top + 2])); 186 203 } 187 204 … … 189 206 190 207 //1バイトコード半角文字 191 if ( use_chars == 1) {192 if (ctrl_code == 0x0D) { // CR208 if (use_chars == 1) { 209 if (ctrl_code == 0x0D) { // CR 193 210 local_x = X_LINE_TO_PIX(hlcd, 0); 194 211 continue; 195 212 } 196 if (ctrl_code == 0x0A) { // LF197 local_y = local_y + 8;213 if (ctrl_code == 0x0A) { // LF 214 local_y = local_y + FONT_HEIGHT; 198 215 continue; 199 216 } 200 217 201 if ( local_x >= hlcd->_width + 4) {218 if (local_x + FONT_HALF_WIDTH > hlcd->_width) { 202 219 local_x = X_LINE_HALF_TO_PIX(hlcd, 0); 203 local_y = local_y + 8;220 local_y = local_y + FONT_HEIGHT; 204 221 } 205 222 lcd_drawFontHalf(hlcd, bitmap_data, local_x, local_y, color, back_color); 206 local_x += 4;223 local_x += FONT_HALF_WIDTH; 207 224 continue; 208 225 } 209 226 210 227 //3バイトコード半角文字 211 if ( use_chars == 3) {212 if ( ( (0xEFBDA1 <= for_3B_hankaku_code) && (for_3B_hankaku_code <= 0xEFBDBF)) ||213 ( (0xEFBE80 <= for_3B_hankaku_code) && (for_3B_hankaku_code <= 0xEFBE9F) )) {228 if (use_chars == 3) { 229 if (((0xEFBDA1 <= for_3B_hankaku_code) && (for_3B_hankaku_code <= 0xEFBDBF)) || 230 ((0xEFBE80 <= for_3B_hankaku_code) && (for_3B_hankaku_code <= 0xEFBE9F))) { 214 231 //3バイトコード半角文字 215 if ( local_x >= hlcd->_width + 4) {232 if (local_x + FONT_HALF_WIDTH > hlcd->_width) { 216 233 local_x = X_LINE_HALF_TO_PIX(hlcd, 0); 217 local_y = local_y + 8;234 local_y = local_y + FONT_HEIGHT; 218 235 } 219 236 lcd_drawFontHalf(hlcd, bitmap_data, local_x, local_y, color, back_color); 220 local_x += 4;237 local_x += FONT_HALF_WIDTH; 221 238 continue; 222 239 } … … 224 241 225 242 //全角文字 226 if ( local_x >= hlcd->_width + 8) {243 if (local_x + FONT_WIDTH > hlcd->_width) { 227 244 local_x = X_LINE_TO_PIX(hlcd, 0); 228 local_y = local_y + 8;245 local_y = local_y + FONT_HEIGHT; 229 246 } 230 247 lcd_drawFont(hlcd, bitmap_data, local_x, local_y, color, back_color); 231 local_x += 8;232 } 233 } 234 248 local_x += FONT_WIDTH; 249 } 250 } 251 -
asp3_tinet_ecnl_arm/trunk/ntshell/lcd/draw_font.h
r352 r364 39 39 #define DRAW_FONT_H 40 40 41 #if defined(SHNM16_FONT) 42 #include "shnm16_font.h" 43 #elif defined(SHNM12_FONT) 44 #include "shnm12_font.h" 45 #else 46 #include "misaki_font.h" 47 #endif 48 41 49 #define DISP_X_ADJ 0 42 50 #define DISP_Y_ADJ 0 43 #define X_ZENKAKU_CHARACTERS(hlcd) ((hlcd)->_width / 8)44 #define X_HANKAKU_CHARACTERS(hlcd) ((hlcd)->_width / 4)45 #define Y_CHARACTERS(hlcd) ((hlcd)->_height / 8)46 #define X_LINE_TO_PIX(hlcd, x) (( 8*(x))-DISP_X_ADJ)47 #define X_LINE_HALF_TO_PIX(hlcd, x) (( 4*(x))-DISP_X_ADJ)48 #define Y_ROW_TO_PIX(hlcd, y) (( 8*(y))-DISP_Y_ADJ)51 #define X_ZENKAKU_CHARACTERS(hlcd) ((hlcd)->_width / FONT_WIDTH) 52 #define X_HANKAKU_CHARACTERS(hlcd) ((hlcd)->_width / FONT_HALF_WIDTH) 53 #define Y_CHARACTERS(hlcd) ((hlcd)->_height / FONT_HEIGHT) 54 #define X_LINE_TO_PIX(hlcd, x) ((FONT_WIDTH*(x))-DISP_X_ADJ) 55 #define X_LINE_HALF_TO_PIX(hlcd, x) ((FONT_HALF_WIDTH*(x))-DISP_X_ADJ) 56 #define Y_ROW_TO_PIX(hlcd, y) ((FONT_HEIGHT*(y))-DISP_Y_ADJ) 49 57 50 58 #ifdef __cplusplus … … 52 60 #endif 53 61 54 void get_bitmap_font(c har *string, unsigned char *bitmap_data, unsigned long*use_chars);55 void lcd_drawFont(LCD_Handler_t *hlcd, u nsigned char *bitmap_data, int x, int y, unsigned short color, unsigned short back_color);56 void lcd_drawFontHalf(LCD_Handler_t *hlcd, u nsigned char *bitmap_data, int x, int y, unsigned short color, unsigned short back_color);57 void lcd_drawString(LCD_Handler_t *hlcd, c har *string, int x, int y, unsigned short color, unsigned short back_color );62 void get_bitmap_font(const uint8_t *string, uint8_t *bitmap_data, uint32_t *use_chars); 63 void lcd_drawFont(LCD_Handler_t *hlcd, uint8_t *bitmap_data, int x, int y, uint16_t color, uint16_t back_color); 64 void lcd_drawFontHalf(LCD_Handler_t *hlcd, uint8_t *bitmap_data, int x, int y, uint16_t color, uint16_t back_color); 65 void lcd_drawString(LCD_Handler_t *hlcd, const char *string, int x, int y, uint16_t color, uint16_t back_color ); 58 66 59 67 #ifdef __cplusplus -
asp3_tinet_ecnl_arm/trunk/ntshell/lcd/misaki_font.c
r352 r364 46 46 47 47 // 1バイトコード 48 unsigned char UTF8_1B_CODE_BITMAP[UTF8_1B_CODE_BITMAP_NUM][8] = {49 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},50 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},51 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},52 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},53 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},54 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},55 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},56 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},57 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},58 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},59 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},60 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},61 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},62 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},63 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},64 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},65 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},66 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},67 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},68 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},69 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},70 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},71 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},72 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},73 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},74 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},75 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},76 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},77 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},78 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},79 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},80 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},81 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},82 {0x4 0, 0x40, 0x40, 0x40, 0x00, 0x40, 0x00, 0x00},83 {0xA 0, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},84 {0xA 0, 0xE0, 0xA0, 0xA0, 0xE0, 0xA0, 0x00, 0x00},85 {0x4 0, 0xE0, 0xC0, 0x60, 0xE0, 0x40, 0x00, 0x00},86 {0x0 0, 0x80, 0x20, 0x40, 0x80, 0x20, 0x00, 0x00},87 {0x4 0, 0xA0, 0x40, 0x60, 0xC0, 0xE0, 0x00, 0x00},88 {0x4 0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},89 {0x2 0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x20, 0x00},90 {0x8 0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x80, 0x00},91 {0x4 0, 0xE0, 0x40, 0xA0, 0x00, 0x00, 0x00, 0x00},92 {0x0 0, 0x40, 0x40, 0xE0, 0x40, 0x40, 0x00, 0x00},93 {0x00, 0x00, 0x0 0, 0x00, 0x00, 0x40, 0x80, 0x00},94 {0x00, 0x0 0, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x00},95 {0x00, 0x00, 0x0 0, 0x00, 0x00, 0x40, 0x00, 0x00},96 {0x00, 0x 00, 0x20, 0x40, 0x80, 0x00, 0x00, 0x00},97 {0x0 0, 0x40, 0xA0, 0xE0, 0xA0, 0x40, 0x00, 0x00},98 {0x0 0, 0x40, 0xC0, 0x40, 0x40, 0xE0, 0x00, 0x00},99 {0x0 0, 0xC0, 0x20, 0x40, 0x80, 0xE0, 0x00, 0x00},100 {0x0 0, 0xC0, 0x20, 0x40, 0x20, 0xC0, 0x00, 0x00},101 {0x0 0, 0x20, 0x60, 0xA0, 0xE0, 0x20, 0x00, 0x00},102 {0x0 0, 0xE0, 0x80, 0xC0, 0x20, 0xC0, 0x00, 0x00},103 {0x0 0, 0x60, 0x80, 0xC0, 0xA0, 0x40, 0x00, 0x00},104 {0x0 0, 0xE0, 0x20, 0x40, 0x40, 0x40, 0x00, 0x00},105 {0x0 0, 0x40, 0xA0, 0x40, 0xA0, 0x40, 0x00, 0x00},106 {0x0 0, 0x40, 0xA0, 0x60, 0x20, 0xC0, 0x00, 0x00},107 {0x00, 0x 00, 0x40, 0x00, 0x00, 0x40, 0x00, 0x00},108 {0x00, 0x 00, 0x40, 0x00, 0x00, 0x40, 0x80, 0x00},109 {0x0 0, 0x20, 0x40, 0x80, 0x40, 0x20, 0x00, 0x00},110 {0x00, 0x 00, 0xE0, 0x00, 0xE0, 0x00, 0x00, 0x00},111 {0x0 0, 0x80, 0x40, 0x20, 0x40, 0x80, 0x00, 0x00},112 {0x4 0, 0xA0, 0x20, 0x40, 0x00, 0x40, 0x00, 0x00},113 {0x4 0, 0xA0, 0x20, 0x60, 0xA0, 0x40, 0x00, 0x00},114 {0x4 0, 0xA0, 0xA0, 0xE0, 0xA0, 0xA0, 0x00, 0x00},115 {0xC 0, 0xA0, 0xC0, 0xA0, 0xA0, 0xC0, 0x00, 0x00},116 {0x6 0, 0x80, 0x80, 0x80, 0x80, 0x60, 0x00, 0x00},117 {0xC 0, 0xA0, 0xA0, 0xA0, 0xA0, 0xC0, 0x00, 0x00},118 {0xE 0, 0x80, 0xC0, 0x80, 0x80, 0xE0, 0x00, 0x00},119 {0xE 0, 0x80, 0xC0, 0x80, 0x80, 0x80, 0x00, 0x00},120 {0x6 0, 0x80, 0x80, 0xA0, 0xA0, 0x60, 0x00, 0x00},121 {0xA 0, 0xA0, 0xA0, 0xE0, 0xA0, 0xA0, 0x00, 0x00},122 {0xE 0, 0x40, 0x40, 0x40, 0x40, 0xE0, 0x00, 0x00},123 {0x2 0, 0x20, 0x20, 0x20, 0xA0, 0x40, 0x00, 0x00},124 {0xA 0, 0xA0, 0xC0, 0xA0, 0xA0, 0xA0, 0x00, 0x00},125 {0x8 0, 0x80, 0x80, 0x80, 0x80, 0xE0, 0x00, 0x00},126 {0xA 0, 0xE0, 0xE0, 0xA0, 0xA0, 0xA0, 0x00, 0x00},127 {0xC 0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0x00, 0x00},128 {0x4 0, 0xA0, 0xA0, 0xA0, 0xA0, 0x40, 0x00, 0x00},129 {0xC 0, 0xA0, 0xA0, 0xC0, 0x80, 0x80, 0x00, 0x00},130 {0x4 0, 0xA0, 0xA0, 0xA0, 0xA0, 0x40, 0x20, 0x00},131 {0xC 0, 0xA0, 0xA0, 0xC0, 0xA0, 0xA0, 0x00, 0x00},132 {0x6 0, 0x80, 0x40, 0x20, 0x20, 0xC0, 0x00, 0x00},133 {0xE 0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00},134 {0xA 0, 0xA0, 0xA0, 0xA0, 0xA0, 0xE0, 0x00, 0x00},135 {0xA 0, 0xA0, 0xA0, 0xA0, 0xC0, 0x80, 0x00, 0x00},136 {0xA 0, 0xA0, 0xA0, 0xE0, 0xE0, 0xA0, 0x00, 0x00},137 {0xA 0, 0xA0, 0x40, 0x40, 0xA0, 0xA0, 0x00, 0x00},138 {0xA 0, 0xA0, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00},139 {0xE 0, 0x20, 0x40, 0x40, 0x80, 0xE0, 0x00, 0x00},140 {0x6 0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x60, 0x00},141 {0xA 0, 0x40, 0xE0, 0x40, 0xE0, 0x40, 0x00, 0x00},142 {0xC 0, 0x40, 0x40, 0x40, 0x40, 0x40, 0xC0, 0x00},143 {0x4 0, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},144 {0x00, 0x00, 0x00, 0x 00, 0x00, 0x00, 0xE0, 0x00},145 {0x4 0, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},146 {0x00, 0x 00, 0x60, 0xA0, 0xA0, 0x60, 0x00, 0x00},147 {0x8 0, 0x80, 0xC0, 0xA0, 0xA0, 0xC0, 0x00, 0x00},148 {0x00, 0x 00, 0x60, 0x80, 0x80, 0x60, 0x00, 0x00},149 {0x2 0, 0x20, 0x60, 0xA0, 0xA0, 0x60, 0x00, 0x00},150 {0x00, 0x 00, 0x60, 0xE0, 0x80, 0x60, 0x00, 0x00},151 {0x6 0, 0x40, 0xE0, 0x40, 0x40, 0x40, 0x00, 0x00},152 {0x00, 0x 00, 0x60, 0xA0, 0x60, 0x20, 0xC0, 0x00},153 {0x8 0, 0x80, 0xC0, 0xA0, 0xA0, 0xA0, 0x00, 0x00},154 {0x40, 0x 00, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00},155 {0x40, 0x 00, 0x40, 0x40, 0x40, 0x40, 0x80, 0x00},156 {0x8 0, 0x80, 0xA0, 0xC0, 0xA0, 0xA0, 0x00, 0x00},157 {0xC 0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00},158 {0x00, 0x 00, 0xC0, 0xE0, 0xE0, 0xA0, 0x00, 0x00},159 {0x00, 0x 00, 0xC0, 0xA0, 0xA0, 0xA0, 0x00, 0x00},160 {0x00, 0x 00, 0x40, 0xA0, 0xA0, 0x40, 0x00, 0x00},161 {0x00, 0x 00, 0xC0, 0xA0, 0xA0, 0xC0, 0x80, 0x00},162 {0x00, 0x 00, 0x60, 0xA0, 0xA0, 0x60, 0x20, 0x00},163 {0x00, 0x 00, 0xA0, 0xC0, 0x80, 0x80, 0x00, 0x00},164 {0x00, 0x 00, 0x60, 0xC0, 0x60, 0xC0, 0x00, 0x00},165 {0x0 0, 0x40, 0xE0, 0x40, 0x40, 0x60, 0x00, 0x00},166 {0x00, 0x 00, 0xA0, 0xA0, 0xA0, 0xE0, 0x00, 0x00},167 {0x00, 0x 00, 0xA0, 0xA0, 0xC0, 0x80, 0x00, 0x00},168 {0x00, 0x 00, 0xA0, 0xA0, 0xE0, 0xE0, 0x00, 0x00},169 {0x00, 0x 00, 0xA0, 0x40, 0x40, 0xA0, 0x00, 0x00},170 {0x00, 0x 00, 0xA0, 0xA0, 0x60, 0x20, 0xC0, 0x00},171 {0x00, 0x 00, 0xE0, 0x20, 0x40, 0xE0, 0x00, 0x00},172 {0x2 0, 0x40, 0x40, 0x80, 0x40, 0x40, 0x20, 0x00},173 {0x4 0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00},174 {0x8 0, 0x40, 0x40, 0x20, 0x40, 0x40, 0x80, 0x00},175 {0xE0, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00},176 {0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00}48 const uint8_t UTF8_1B_CODE_BITMAP[UTF8_1B_CODE_BITMAP_NUM][FONT_HALF_WIDTH * FONT_HEIGHT / 8] = { 49 {0x00, 0x00, 0x00, 0x00}, 50 {0x00, 0x00, 0x00, 0x00}, 51 {0x00, 0x00, 0x00, 0x00}, 52 {0x00, 0x00, 0x00, 0x00}, 53 {0x00, 0x00, 0x00, 0x00}, 54 {0x00, 0x00, 0x00, 0x00}, 55 {0x00, 0x00, 0x00, 0x00}, 56 {0x00, 0x00, 0x00, 0x00}, 57 {0x00, 0x00, 0x00, 0x00}, 58 {0x00, 0x00, 0x00, 0x00}, 59 {0x00, 0x00, 0x00, 0x00}, 60 {0x00, 0x00, 0x00, 0x00}, 61 {0x00, 0x00, 0x00, 0x00}, 62 {0x00, 0x00, 0x00, 0x00}, 63 {0x00, 0x00, 0x00, 0x00}, 64 {0x00, 0x00, 0x00, 0x00}, 65 {0x00, 0x00, 0x00, 0x00}, 66 {0x00, 0x00, 0x00, 0x00}, 67 {0x00, 0x00, 0x00, 0x00}, 68 {0x00, 0x00, 0x00, 0x00}, 69 {0x00, 0x00, 0x00, 0x00}, 70 {0x00, 0x00, 0x00, 0x00}, 71 {0x00, 0x00, 0x00, 0x00}, 72 {0x00, 0x00, 0x00, 0x00}, 73 {0x00, 0x00, 0x00, 0x00}, 74 {0x00, 0x00, 0x00, 0x00}, 75 {0x00, 0x00, 0x00, 0x00}, 76 {0x00, 0x00, 0x00, 0x00}, 77 {0x00, 0x00, 0x00, 0x00}, 78 {0x00, 0x00, 0x00, 0x00}, 79 {0x00, 0x00, 0x00, 0x00}, 80 {0x00, 0x00, 0x00, 0x00}, 81 {0x00, 0x00, 0x00, 0x00}, 82 {0x44, 0x44, 0x04, 0x00}, 83 {0xAA, 0x00, 0x00, 0x00}, 84 {0xAE, 0xAA, 0xEA, 0x00}, 85 {0x4E, 0xC6, 0xE4, 0x00}, 86 {0x08, 0x24, 0x82, 0x00}, 87 {0x4A, 0x46, 0xCE, 0x00}, 88 {0x48, 0x00, 0x00, 0x00}, 89 {0x24, 0x44, 0x44, 0x20}, 90 {0x84, 0x44, 0x44, 0x80}, 91 {0x4E, 0x4A, 0x00, 0x00}, 92 {0x04, 0x4E, 0x44, 0x00}, 93 {0x00, 0x00, 0x04, 0x80}, 94 {0x00, 0x0E, 0x00, 0x00}, 95 {0x00, 0x00, 0x04, 0x00}, 96 {0x00, 0x24, 0x80, 0x00}, 97 {0x04, 0xAE, 0xA4, 0x00}, 98 {0x04, 0xC4, 0x4E, 0x00}, 99 {0x0C, 0x24, 0x8E, 0x00}, 100 {0x0C, 0x24, 0x2C, 0x00}, 101 {0x02, 0x6A, 0xE2, 0x00}, 102 {0x0E, 0x8C, 0x2C, 0x00}, 103 {0x06, 0x8C, 0xA4, 0x00}, 104 {0x0E, 0x24, 0x44, 0x00}, 105 {0x04, 0xA4, 0xA4, 0x00}, 106 {0x04, 0xA6, 0x2C, 0x00}, 107 {0x00, 0x40, 0x04, 0x00}, 108 {0x00, 0x40, 0x04, 0x80}, 109 {0x02, 0x48, 0x42, 0x00}, 110 {0x00, 0xE0, 0xE0, 0x00}, 111 {0x08, 0x42, 0x48, 0x00}, 112 {0x4A, 0x24, 0x04, 0x00}, 113 {0x4A, 0x26, 0xA4, 0x00}, 114 {0x4A, 0xAE, 0xAA, 0x00}, 115 {0xCA, 0xCA, 0xAC, 0x00}, 116 {0x68, 0x88, 0x86, 0x00}, 117 {0xCA, 0xAA, 0xAC, 0x00}, 118 {0xE8, 0xC8, 0x8E, 0x00}, 119 {0xE8, 0xC8, 0x88, 0x00}, 120 {0x68, 0x8A, 0xA6, 0x00}, 121 {0xAA, 0xAE, 0xAA, 0x00}, 122 {0xE4, 0x44, 0x4E, 0x00}, 123 {0x22, 0x22, 0xA4, 0x00}, 124 {0xAA, 0xCA, 0xAA, 0x00}, 125 {0x88, 0x88, 0x8E, 0x00}, 126 {0xAE, 0xEA, 0xAA, 0x00}, 127 {0xCA, 0xAA, 0xAA, 0x00}, 128 {0x4A, 0xAA, 0xA4, 0x00}, 129 {0xCA, 0xAC, 0x88, 0x00}, 130 {0x4A, 0xAA, 0xA4, 0x20}, 131 {0xCA, 0xAC, 0xAA, 0x00}, 132 {0x68, 0x42, 0x2C, 0x00}, 133 {0xE4, 0x44, 0x44, 0x00}, 134 {0xAA, 0xAA, 0xAE, 0x00}, 135 {0xAA, 0xAA, 0xC8, 0x00}, 136 {0xAA, 0xAE, 0xEA, 0x00}, 137 {0xAA, 0x44, 0xAA, 0x00}, 138 {0xAA, 0x44, 0x44, 0x00}, 139 {0xE2, 0x44, 0x8E, 0x00}, 140 {0x64, 0x44, 0x44, 0x60}, 141 {0xA4, 0xE4, 0xE4, 0x00}, 142 {0xC4, 0x44, 0x44, 0xC0}, 143 {0x4A, 0x00, 0x00, 0x00}, 144 {0x00, 0x00, 0x00, 0xE0}, 145 {0x42, 0x00, 0x00, 0x00}, 146 {0x00, 0x6A, 0xA6, 0x00}, 147 {0x88, 0xCA, 0xAC, 0x00}, 148 {0x00, 0x68, 0x86, 0x00}, 149 {0x22, 0x6A, 0xA6, 0x00}, 150 {0x00, 0x6E, 0x86, 0x00}, 151 {0x64, 0xE4, 0x44, 0x00}, 152 {0x00, 0x6A, 0x62, 0xC0}, 153 {0x88, 0xCA, 0xAA, 0x00}, 154 {0x40, 0x44, 0x44, 0x00}, 155 {0x40, 0x44, 0x44, 0x80}, 156 {0x88, 0xAC, 0xAA, 0x00}, 157 {0xC4, 0x44, 0x44, 0x00}, 158 {0x00, 0xCE, 0xEA, 0x00}, 159 {0x00, 0xCA, 0xAA, 0x00}, 160 {0x00, 0x4A, 0xA4, 0x00}, 161 {0x00, 0xCA, 0xAC, 0x80}, 162 {0x00, 0x6A, 0xA6, 0x20}, 163 {0x00, 0xAC, 0x88, 0x00}, 164 {0x00, 0x6C, 0x6C, 0x00}, 165 {0x04, 0xE4, 0x46, 0x00}, 166 {0x00, 0xAA, 0xAE, 0x00}, 167 {0x00, 0xAA, 0xC8, 0x00}, 168 {0x00, 0xAA, 0xEE, 0x00}, 169 {0x00, 0xA4, 0x4A, 0x00}, 170 {0x00, 0xAA, 0x62, 0xC0}, 171 {0x00, 0xE2, 0x4E, 0x00}, 172 {0x24, 0x48, 0x44, 0x20}, 173 {0x44, 0x44, 0x44, 0x40}, 174 {0x84, 0x42, 0x44, 0x80}, 175 {0xE0, 0x00, 0x00, 0x00}, 176 {0x00, 0x00, 0x00, 0x00} 177 177 }; 178 178 179 179 // 2バイトコード 1バイト目 180 unsigned charUtf8CodeTable_2B_1st[UTF8_CODE_2B_1_NUM][2] = {180 const uint8_t Utf8CodeTable_2B_1st[UTF8_CODE_2B_1_NUM][2] = { 181 181 {0xC2, 0x06}, 182 182 {0xC3, 0x02}, … … 187 187 }; 188 188 // 2バイトコード 2バイト目 bitmapデータ 189 struct utf8_code_bitmap UTF8_2B_CODE_BITMAP[UTF8_2B_CODE_BITMAP_NUM] = {189 const struct utf8_code_bitmap UTF8_2B_CODE_BITMAP[UTF8_2B_CODE_BITMAP_NUM] = { 190 190 {0xA7, {0x1C, 0x20, 0x18, 0x24, 0x18, 0x04, 0x38, 0x00}}, 191 191 {0xA8, {0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, … … 313 313 314 314 // 3バイトコード 1バイト目 315 unsigned charUtf8CodeTable_3B_1st[UTF8_CODE_3B_1_NUM][2] = {315 const uint8_t Utf8CodeTable_3B_1st[UTF8_CODE_3B_1_NUM][2] = { 316 316 {0xE2, 0x0E}, 317 317 {0xE3, 0x04}, … … 325 325 }; 326 326 // 3バイトコード 2バイト目 327 unsigned charUtf8CodeTable_3B_2nd[UTF8_CODE_3B_2_NUM][2] = {327 const uint8_t Utf8CodeTable_3B_2nd[UTF8_CODE_3B_2_NUM][2] = { 328 328 {0x80, 0x0F}, 329 329 {0x84, 0x02}, … … 673 673 674 674 // 3バイトコード 3バイト目 bitmapデータ 675 struct utf8_code_bitmap UTF8_3B_CODE_BITMAP[UTF8_3B_CODE_BITMAP_NUM] = {675 const struct utf8_code_bitmap UTF8_3B_CODE_BITMAP[UTF8_3B_CODE_BITMAP_NUM] = { 676 676 { 0x90 ,{0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00}}, 677 677 { 0x95 ,{0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00}}, -
asp3_tinet_ecnl_arm/trunk/ntshell/lcd/misaki_font.h
r352 r364 39 39 #define MISAKI_FONT_H 40 40 41 #include <stdint.h> 42 43 #define FONT_HALF_WIDTH 4 44 #define FONT_WIDTH 8 45 #define FONT_HEIGHT 8 46 41 47 struct utf8_code_bitmap { 42 unsigned charcode;43 unsigned char bitmap[8];48 const uint8_t code; 49 const uint8_t bitmap[FONT_WIDTH * FONT_HEIGHT / 8]; 44 50 }; 45 51 … … 48 54 #define UTF8_CODE_3B_2_NUM (343+1) /*半角追加2/2*/ 49 55 50 #define UTF8_CODE_BITMAP_NUM 6879 /*トータル*/51 56 #define UTF8_1B_CODE_BITMAP_NUM 128 52 57 #define UTF8_2B_CODE_BITMAP_NUM 122 /*"¬","\","¢""£"移動)*/ … … 54 59 55 60 // 1バイトコード 56 extern unsigned char UTF8_1B_CODE_BITMAP[UTF8_1B_CODE_BITMAP_NUM][8];61 extern const uint8_t UTF8_1B_CODE_BITMAP[UTF8_1B_CODE_BITMAP_NUM][FONT_HALF_WIDTH * FONT_HEIGHT / 8]; 57 62 58 63 // 2バイトコード 1バイト目 59 extern unsigned charUtf8CodeTable_2B_1st[UTF8_CODE_2B_1_NUM][2];64 extern const uint8_t Utf8CodeTable_2B_1st[UTF8_CODE_2B_1_NUM][2]; 60 65 // 2バイトコード 2バイト目 bitmapデータ 61 extern struct utf8_code_bitmap UTF8_2B_CODE_BITMAP[UTF8_2B_CODE_BITMAP_NUM];66 extern const struct utf8_code_bitmap UTF8_2B_CODE_BITMAP[UTF8_2B_CODE_BITMAP_NUM]; 62 67 63 68 // 3バイトコード 1バイト目 64 extern unsigned charUtf8CodeTable_3B_1st[UTF8_CODE_3B_1_NUM][2];69 extern const uint8_t Utf8CodeTable_3B_1st[UTF8_CODE_3B_1_NUM][2]; 65 70 // 3バイトコード 2バイト目 66 extern unsigned charUtf8CodeTable_3B_2nd[UTF8_CODE_3B_2_NUM][2];71 extern const uint8_t Utf8CodeTable_3B_2nd[UTF8_CODE_3B_2_NUM][2]; 67 72 68 73 // 3バイトコード 3バイト目 bitmapデータ 69 extern struct utf8_code_bitmap UTF8_3B_CODE_BITMAP[UTF8_3B_CODE_BITMAP_NUM];74 extern const struct utf8_code_bitmap UTF8_3B_CODE_BITMAP[UTF8_3B_CODE_BITMAP_NUM]; 70 75 71 76 #endif /* MISAKI_FONT_H */ -
asp3_tinet_ecnl_arm/trunk/ntshell/src/echonet_app_config.h
r352 r364 40 40 41 41 #define ECHONET_TASK_STACK_SIZE 1024 /* ECNL UDPタスク用スタック領域のサイズ */ 42 43 #define ECHONET_API_DATAQUEUE_COUNT 5 /* ECHONET Lite API用データキュー */ 44 #define ECHONET_SVC_DATAQUEUE_COUNT 5 /* ECHONET Lite サービス処理タスク用データキュー */ 45 #define ECHONET_UDP_DATAQUEUE_COUNT 5 /* ECHONET Lite UDP通信処理用データキュー */ 42 46 43 47 /* -
asp3_tinet_ecnl_arm/trunk/ntshell/src/fdtable.c
r359 r364 45 45 #include "target_syssvc.h" 46 46 #ifndef NTSHELL_NO_SOCKET 47 #include <tinet_defs.h> 47 48 #include <tinet_config.h> 49 #include <net/net.h> 50 #include <net/net_endian.h> 48 51 #include <netinet/in.h> 49 52 #include <netinet/in_itron.h> … … 55 58 #include <net/net.h> 56 59 #include <net/if_var.h> 60 #include <netinet/udp.h> 57 61 #include <netinet/udp_var.h> 58 62 #include <netinet/tcp.h> 59 63 #include <netinet/tcp_var.h> 64 #include <net/net_buf.h> 60 65 #endif 61 66 #include "ff.h" … … 69 74 #define IO_TYPE_DIR 3 70 75 #define IO_TYPE_TCP 4 71 #define IO_TYPE_UDP 76 #define IO_TYPE_UDP 5 72 77 73 78 static struct _IO_FILE fd_table[8 * sizeof(FLGPTN)] = { … … 85 90 continue; 86 91 92 memset(fp, 0, sizeof(struct _IO_FILE)); 87 93 fp->fd = fd; 88 94 fp->type = type; … … 280 286 #endif 281 287 288 void memor(void *dst, void *src, size_t len) 289 { 290 uint8_t *d = (uint8_t *)dst; 291 uint8_t *s = (uint8_t *)src; 292 uint8_t *e = &s[len]; 293 294 while (s < e) { 295 *d++ |= *s++; 296 } 297 } 298 282 299 struct fd_events { 283 300 int count; … … 304 321 } 305 322 306 memcpy(&evts.readfds, rfds, sizeof(fd_set)); 307 memcpy(&evts.writefds, wfds, sizeof(fd_set)); 308 memcpy(&evts.errorfds, efds, sizeof(fd_set)); 323 if (rfds != NULL) 324 memcpy(&evts.readfds, rfds, sizeof(fd_set)); 325 else 326 memset(&evts.readfds, 0, sizeof(fd_set)); 327 if (wfds != NULL) 328 memcpy(&evts.writefds, wfds, sizeof(fd_set)); 329 else 330 memset(&evts.writefds, 0, sizeof(fd_set)); 331 if (efds != NULL) 332 memcpy(&evts.errorfds, efds, sizeof(fd_set)); 333 else 334 memset(&evts.errorfds, 0, sizeof(fd_set)); 309 335 evts.count = 0; 310 336 311 337 ret = shell_get_evts(&evts, tmout); 338 if (rfds != NULL) 339 memset(rfds, 0, sizeof(fd_set)); 340 if (wfds != NULL) 341 memset(wfds, 0, sizeof(fd_set)); 342 if (efds != NULL) 343 memset(efds, 0, sizeof(fd_set)); 312 344 if (ret == E_OK) { 313 memcpy(rfds, &evts.readfds, sizeof(fd_set)); 314 memcpy(wfds, &evts.writefds, sizeof(fd_set)); 315 memcpy(efds, &evts.errorfds, sizeof(fd_set)); 345 if (rfds != NULL) 346 memor(rfds, &evts.readfds, sizeof(fd_set)); 347 if (wfds != NULL) 348 memor(wfds, &evts.writefds, sizeof(fd_set)); 349 if (efds != NULL) 350 memor(efds, &evts.errorfds, sizeof(fd_set)); 316 351 return evts.count; 317 352 } 318 353 if (ret == E_TMOUT) { 319 memset(rfds, 0, sizeof(fd_set));320 memset(wfds, 0, sizeof(fd_set));321 memset(efds, 0, sizeof(fd_set));322 354 return 0; 323 355 } … … 441 473 struct _IO_FILE *fp = tcpid_to_fd(cepid); 442 474 FLGPTN flgptn = 0; 475 ER ret; 476 int len; 443 477 444 478 if (fp == NULL) … … 449 483 450 484 switch (fncd) { 485 case TFN_TCP_RCV_BUF: 486 len = *(int *)p_parblk; 487 if (len <= 0) 488 return E_OK; 489 490 ret = wai_sem(SEM_FILEDESC); 491 if (ret < 0) { 492 syslog(LOG_ERROR, "wai_sem => %d", ret); 493 } 494 fp->psock->len += len; 495 ret = sig_sem(SEM_FILEDESC); 496 if (ret < 0) { 497 syslog(LOG_ERROR, "sig_sem => %d", ret); 498 } 499 500 if (fp->readevt_w == fp->readevt_r) fp->readevt_w++; 501 502 set_flg(FLG_SELECT_WAIT, flgptn); 503 return E_OK; 504 451 505 case TFN_TCP_RCV_DAT: 506 len = *(int *)p_parblk; 507 if (len <= 0) 508 return E_OK; 509 510 ret = wai_sem(SEM_FILEDESC); 511 if (ret < 0) { 512 syslog(LOG_ERROR, "wai_sem => %d", ret); 513 } 514 fp->psock->len += len; 515 ret = sig_sem(SEM_FILEDESC); 516 if (ret < 0) { 517 syslog(LOG_ERROR, "sig_sem => %d", ret); 518 } 519 452 520 if (fp->readevt_w == fp->readevt_r) fp->readevt_w++; 453 521 … … 484 552 struct _IO_FILE *fp = udpid_to_fd(cepid); 485 553 FLGPTN flgptn = 0; 554 int len; 486 555 487 556 if (fp == NULL) … … 492 561 493 562 switch (fncd) { 563 case TEV_UDP_RCV_DAT: 564 { 565 T_UDP_RCV_DAT_PARA *udppara = (T_UDP_RCV_DAT_PARA *)p_parblk; 566 len = udppara->len; 567 if (len <= 0) 568 return E_OK; 569 570 ER ret = wai_sem(SEM_FILEDESC); 571 if (ret < 0) { 572 syslog(LOG_ERROR, "wai_sem => %d", ret); 573 } 574 fp->psock->len = len; 575 if (fp->psock->input != NULL) { 576 ret = rel_net_buf(fp->psock->input); 577 if (ret < 0) { 578 syslog(LOG_ERROR, "rel_net_buf => %d", ret); 579 } 580 } 581 fp->psock->input = udppara->input; 582 fp->psock->buf = GET_UDP_SDU(udppara->input, udppara->off); 583 memset(&fp->psock->raddr4, 0, sizeof(fp->psock->raddr4)); 584 fp->psock->raddr4.sin_family = AF_INET; 585 fp->psock->raddr4.sin_port = htons(udppara->rep4.portno); 586 fp->psock->raddr4.sin_addr.s_addr = htonl(udppara->rep4.ipaddr); 587 udppara->input->flags |= NB_FLG_NOREL_IFOUT; 588 ret = sig_sem(SEM_FILEDESC); 589 if (ret < 0) { 590 syslog(LOG_ERROR, "sig_sem => %d", ret); 591 } 592 593 if (fp->readevt_w == fp->readevt_r) fp->readevt_w++; 594 595 set_flg(FLG_SELECT_WAIT, flgptn); 596 return E_OK; 597 } 494 598 case TFN_UDP_CRE_CEP: 599 return E_OK; 600 495 601 case TFN_UDP_RCV_DAT: 602 len = *(int *)p_parblk; 603 if (len <= 0) 604 return E_OK; 605 496 606 if (fp->readevt_w == fp->readevt_r) fp->readevt_w++; 497 607 … … 524 634 ER shell_get_evts(struct fd_events *evts, TMO tmout) 525 635 { 526 ER ret;527 FLGPTN waitptn, flgptn = 0, readfds = 0, writefds = 0;528 struct _IO_FILE *fp = NULL;529 636 int count = 0; 530 531 stdio_update_evts(); 637 SYSTIM prev, now; 638 639 get_tim(&prev); 640 641 for (;;) { 642 ER ret; 643 FLGPTN waitptn, flgptn, readfds = 0, writefds = 0; 644 struct _IO_FILE *fp = NULL; 645 646 stdio_update_evts(); 532 647 533 648 #ifndef NTSHELL_NO_SOCKET 534 waitptn = *((FLGPTN *)&evts->errorfds);649 waitptn = *((FLGPTN *)&evts->errorfds); 535 650 #else 536 waitptn = *((FLGPTN *)&evts->readfds) | *((FLGPTN *)&evts->errorfds);651 waitptn = *((FLGPTN *)&evts->readfds) | *((FLGPTN *)&evts->errorfds); 537 652 #endif 538 for (int fd = 0; fd < fd_table_count; fd++) {539 fp = &fd_table[fd];653 for (int fd = 0; fd < fd_table_count; fd++) { 654 fp = &fd_table[fd]; 540 655 541 656 #ifndef NTSHELL_NO_SOCKET 542 if (FD_ISSET(fd, &evts->readfds)) { 543 if ((fp->type == IO_TYPE_TCP) 544 && (GET_TCP_CEP(fp->psock->cepid)->rwbuf_count > 0)) { 545 FD_SET(fd, (fd_set *)&readfds); 546 count++; 547 if (fp->readevt_w == fp->readevt_r) fp->readevt_r--; 657 if (FD_ISSET(fd, &evts->readfds)) { 658 if ((fp->type == IO_TYPE_TCP) && (fp->psock->cepid != 0)) { 659 if (fp->psock->len == 0) { 660 ret = tcp_rcv_buf(fp->psock->cepid, &fp->psock->input, TMO_NBLK); 661 if ((ret != E_WBLK) && (ret != E_OBJ) && (ret < 0)) { 662 syslog(LOG_ERROR, "tcp_rcv_buf => %d", ret); 663 //return ret; 664 } 665 if (ret > 0) { 666 ret = wai_sem(SEM_FILEDESC); 667 if (ret < 0) { 668 syslog(LOG_ERROR, "wai_sem => %d", ret); 669 } 670 fp->psock->len += ret; 671 ret = sig_sem(SEM_FILEDESC); 672 if (ret < 0) { 673 syslog(LOG_ERROR, "sig_sem => %d", ret); 674 } 675 } 676 } 677 else ret = 1; 678 if (ret > 0) { 679 FD_SET(fd, (fd_set *)&readfds); 680 count++; 681 if (fp->readevt_w == fp->readevt_r) fp->readevt_r--; 682 } 683 } 684 else if ((fp->type == IO_TYPE_UDP) && (fp->psock->cepid != 0)) { 685 if (fp->psock->input != NULL) { 686 FD_SET(fd, (fd_set *)&readfds); 687 count++; 688 if (fp->readevt_w == fp->readevt_r) fp->readevt_r--; 689 } 690 } 691 else { 692 FD_SET(fd, (fd_set *)&waitptn); 693 } 548 694 } 549 else { 550 FD_SET(fd, (fd_set *)&waitptn); 695 #endif 696 if (FD_ISSET(fd, &evts->writefds)) { 697 if (fp->writeevt_w == fp->writeevt_r) { 698 FD_SET(fd, (fd_set *)&writefds); 699 count++; 700 if (fp->writeevt_w == fp->writeevt_r) fp->writeevt_r--; 701 } 702 else { 703 FD_SET(fd, (fd_set *)&waitptn); 704 } 551 705 } 552 706 } 553 #endif 554 if (FD_ISSET(fd, &evts->writefds)) { 555 if (fp->writable) { 556 FD_SET(fd, (fd_set *)&writefds); 707 memset(evts, 0, sizeof(*evts)); 708 709 if (waitptn == 0) { 710 memcpy(&evts->readfds, &readfds, sizeof(evts->readfds)); 711 memcpy(&evts->writefds, &writefds, sizeof(evts->writefds)); 712 evts->count = count; 713 return E_OK; 714 } 715 else if ((readfds | writefds) != 0) { 716 set_flg(FLG_SELECT_WAIT, (readfds | writefds)); 717 } 718 719 /* イベント待ち */ 720 flgptn = 0; 721 ret = twai_flg(FLG_SELECT_WAIT, waitptn, TWF_ORW, &flgptn, tmout); 722 if (ret != E_OK) { 723 if (ret != E_TMOUT) { 724 syslog(LOG_ERROR, "twai_flg => %d", ret); 725 return ret; 726 } 727 728 stdio_flgptn(&flgptn); 729 730 if (flgptn == 0) 731 return E_TMOUT; 732 } 733 flgptn &= waitptn; 734 735 /* 受け取ったフラグのみクリア */ 736 ret = clr_flg(FLG_SELECT_WAIT, ~flgptn); 737 if (ret != E_OK) { 738 syslog(LOG_ERROR, "clr_flg => %d", ret); 739 } 740 741 count = 0; 742 for (int fd = 0; fd < fd_table_count; fd++) { 743 if (!FD_ISSET(fd, (fd_set *)&waitptn)) 744 continue; 745 746 fp = &fd_table[fd]; 747 748 if (fp->readevt_w != fp->readevt_r) { 749 fp->readevt_r++; 750 FD_SET(fd, &evts->readfds); 557 751 count++; 558 752 } 559 else { 560 FD_SET(fd, (fd_set *)&waitptn); 753 if (fp->writeevt_w != fp->writeevt_r) { 754 fp->writeevt_r++; 755 fp->writable = 1; 561 756 } 562 } 563 } 564 memset(evts, 0, sizeof(*evts)); 565 566 if (waitptn == 0) { 567 memcpy(&evts->readfds, &readfds, sizeof(evts->readfds)); 568 memcpy(&evts->writefds, &writefds, sizeof(evts->writefds)); 569 evts->count = count; 570 return E_OK; 571 } 572 else if ((readfds | writefds) != 0){ 573 set_flg(FLG_SELECT_WAIT, (readfds | writefds)); 574 } 575 576 /* イベント待ち */ 577 ret = twai_flg(FLG_SELECT_WAIT, waitptn, TWF_ORW, &flgptn, tmout); 578 if (ret != E_OK) { 579 if (ret != E_TMOUT) { 580 syslog(LOG_ERROR, "twai_flg => %d", ret); 581 return ret; 582 } 583 584 stdio_flgptn(&flgptn); 585 586 if (flgptn == 0) 757 if (fp->writable) { 758 FD_SET(fd, &evts->writefds); 759 count++; 760 } 761 if (fp->errorevt_w != fp->errorevt_r) { 762 fp->errorevt_r++; 763 FD_SET(fd, &evts->errorfds); 764 count++; 765 } 766 } 767 768 if (count > 0) 769 break; 770 771 get_tim(&now); 772 773 SYSTIM elapse = now - prev; 774 if (elapse > tmout) 587 775 return E_TMOUT; 588 } 589 flgptn &= waitptn; 590 591 /* 受け取ったフラグのみクリア */ 592 ret = clr_flg(FLG_SELECT_WAIT, ~flgptn); 593 if (ret != E_OK) { 594 syslog(LOG_ERROR, "clr_flg => %d", ret); 595 } 596 597 count = 0; 598 for (int fd = 0; fd < fd_table_count; fd++) { 599 if (!FD_ISSET(fd, (fd_set *)&waitptn)) 600 continue; 601 602 fp = &fd_table[fd]; 603 604 if (fp->readevt_w != fp->readevt_r) { 605 fp->readevt_r++; 606 FD_SET(fd, &evts->readfds); 607 count++; 608 } 609 if (fp->writeevt_w != fp->writeevt_r) { 610 fp->writeevt_r++; 611 fp->writable = 1; 612 } 613 if (fp->writable) { 614 FD_SET(fd, &evts->writefds); 615 count++; 616 } 617 if (fp->errorevt_w != fp->errorevt_r) { 618 fp->errorevt_r++; 619 FD_SET(fd, &evts->errorfds); 620 count++; 621 } 622 } 776 777 prev = now; 778 tmout -= elapse; 779 } 780 623 781 evts->count = count; 624 782 … … 676 834 } 677 835 678 ssize_t shell_send(int fd, const void *buf, size_t len, int flags)679 {680 return -ENOMEM;681 }682 683 836 ssize_t shell_sendto(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t alen) 684 837 { … … 691 844 } 692 845 693 ssize_t shell_recv(int fd, void *buf, size_t len, int flags) 694 { 695 return -ENOMEM; 696 } 697 698 ssize_t shell_recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr *__restrict addr, socklen_t *__restrict alen) 846 ssize_t shell_recvfrom(int fd, void *__restrict buf, size_t len, int flags, struct sockaddr *__restrict addr, socklen_t *__restrict alen) 699 847 { 700 848 return -ENOMEM; -
asp3_tinet_ecnl_arm/trunk/ntshell/src/net_misc.h
r352 r364 41 41 /* スタックサイズ */ 42 42 43 #define NET_MISC_STACK_SIZE 1024/* NTP クライアントタスク(IPv4)のスタックサイズ */43 #define NET_MISC_STACK_SIZE 2048 /* NTP クライアントタスク(IPv4)のスタックサイズ */ 44 44 45 45 /* 優先度 */ -
asp3_tinet_ecnl_arm/trunk/ntshell/src/netcmd.c
r352 r364 239 239 int usrcmd_ping(int argc, char **argv) 240 240 { 241 int tmo, size;242 char 241 int tmo = 3, size = 64; 242 char apip = DEFAULT_API_PROTO; 243 243 char *line = argv[1]; 244 244 #if defined(SUPPORT_INET6) … … 262 262 263 263 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) 264 if (argc <= 2) 265 return 0; 266 264 267 if ('0' <= *line && *line <= '9') { 265 268 if (*line == '6') … … 269 272 line++; 270 273 } 274 275 line = argv[2]; 276 #else 277 if (argc <= 1) 278 return 0; 271 279 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 272 280 … … 276 284 } 277 285 278 line = argv[2];279 if ('0' <= *line && *line <= '9')280 line = get_int(&tmo, line);281 else282 tmo = 3; 283 284 line = argv[3];285 if ('0' <= *line && *line <= '9')286 line = get_int(&size, line);287 else288 size = 64;286 if (argc > 2) { 287 line = argv[2]; 288 if ('0' <= *line && *line <= '9') 289 line = get_int(&tmo, line); 290 291 if (argc > 3) { 292 line = argv[3]; 293 if ('0' <= *line && *line <= '9') 294 line = get_int(&size, line); 295 } 296 } 289 297 290 298 #if defined(SUPPORT_INET6) … … 337 345 { 338 346 ER ret; 347 348 if (argc < 2) 349 return 0; 350 339 351 if (ntlibc_strcmp(argv[1], "rel") == 0) { 340 352 ret = dhcp4c_rel_info(); … … 348 360 dhcp4c_info(); 349 361 } 362 350 363 return 0; 351 364 } -
asp3_tinet_ecnl_arm/trunk/ntshell/src/ntp_cli.c
r359 r364 265 265 266 266 nc->buf[0] = '\0'; 267 #if ndef _MSC_VER267 #ifdef __NEED_struct_timespec 268 268 if (ctime_r(&tp.tv_sec, nc->buf) != NULL) 269 269 #else -
asp3_tinet_ecnl_arm/trunk/ntshell/src/ntshell_main.c
r352 r364 69 69 const struct utsname host_name = { 70 70 "TOPPERS/ASP3", 71 72 73 74 75 71 TARGET_NAME, 72 "3.2.0", 73 "3.2.0", 74 TARGET_NAME, 75 "toppers.jp" 76 76 }; 77 77 … … 88 88 jmp_buf process_exit; 89 89 void sys_init(void); 90 91 void ntshell_task_init() 92 { 90 NTSHELL_SERIAL_READ ntshell_serial_read = 0; 91 NTSHELL_SERIAL_WRITE ntshell_serial_write = 0; 92 void *ntshell_serial_extobj; 93 94 unsigned char ntstdio_xi(struct ntstdio_t *handle) 95 { 96 unsigned char buf[1]; 97 ntshell_serial_read((char *)buf, 1, ntshell_serial_extobj); 98 return buf[0]; 99 } 100 101 void ntstdio_xo(struct ntstdio_t *handle, unsigned char c) 102 { 103 char buf[1]; 104 buf[0] = c; 105 ntshell_serial_write(buf, 1, ntshell_serial_extobj); 106 } 107 108 void ntshell_task_init(NTSHELL_SERIAL_READ func_read, 109 NTSHELL_SERIAL_WRITE func_write, void *extobj) 110 { 111 ntshell_serial_read = func_read; 112 ntshell_serial_write = func_write; 113 ntshell_serial_extobj = extobj; 114 93 115 sys_init(); 94 116 … … 126 148 int result = 0; 127 149 int found = 0; 150 151 if (*args == 0) 152 return result; 128 153 129 154 if (strcmp((const char *)args[1], "help") == 0) { … … 295 320 int shell_clock_getres(clockid_t clk_id, struct timespec *res) 296 321 { 297 if ( clk_id != CLOCK_REALTIME)322 if ((clk_id != CLOCK_REALTIME) && (clk_id != CLOCK_MONOTONIC)) 298 323 return -EINVAL; 299 324 … … 308 333 SYSTIM now = 0; 309 334 310 if ( clk_id != CLOCK_REALTIME)335 if ((clk_id != CLOCK_REALTIME) && (clk_id != CLOCK_MONOTONIC)) 311 336 return -EINVAL; 312 337 … … 320 345 int shell_clock_settime(clockid_t clk_id, const struct timespec *tp) 321 346 { 322 if ( clk_id != CLOCK_REALTIME)347 if ((clk_id != CLOCK_REALTIME) && (clk_id != CLOCK_MONOTONIC)) 323 348 return -EINVAL; 324 349 325 rtc_write(tp->tv_sec); 350 SYSTIM time; 351 ER ret; 352 353 time = (tp->tv_sec * 1000000ll) + (tp->tv_nsec / 1000ll); 354 355 ret = set_tim(time); 356 if (ret != E_OK) { 357 return -EPERM; 358 } 326 359 327 360 return 0; … … 356 389 } 357 390 358 struct sigaction sigtable[ 6];391 struct sigaction sigtable[7]; 359 392 360 393 int shell_sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old) … … 381 414 sat = &sigtable[5]; 382 415 break; 416 case SIGPIPE: 417 sat = &sigtable[6]; 418 break; 383 419 default: 384 420 return -EINVAL; -
asp3_tinet_ecnl_arm/trunk/ntshell/src/ntshell_main.cfg
r352 r364 43 43 CRE_TSK(NTSHELL_TASK, { TA_NULL, 0, ntshell_task, NTSHELL_PRIORITY, NTSHELL_STACK_SIZE, NULL }); 44 44 CRE_FLG(FLG_SELECT_WAIT, { TA_WMUL, 0x00 }); 45 CRE_SEM(SEM_FILEDESC, { TA_TPRI, 1, 1 }); 45 46 CRE_SEM(SEM_MALLOC, { TA_TPRI, 1, 1 }); -
asp3_tinet_ecnl_arm/trunk/ntshell/src/ntshell_main.h
r352 r364 49 49 50 50 #include "usrcmd.h" 51 #include "core/ntshell.h" 51 52 52 53 /* … … 54 55 */ 55 56 56 #define NTSHELL_PRIORITY 4/* ntshellタスクの優先度 */57 #define NTSHELL_PRIORITY 8 /* ntshellタスクの優先度 */ 57 58 58 59 #define NTSHELL_STACK_SIZE 8192 /* ntshellタスクのスタック領域のサイズ */ … … 75 76 extern PRI main_task_priority; 76 77 77 struct ntstdio_t;78 unsigned char ntstdio_xi(struct ntstdio_t *handle);79 void ntstdio_xo(struct ntstdio_t *handle, unsigned char c);80 81 78 /* ntshellタスク初期化 */ 82 void ntshell_task_init(); 79 void ntshell_task_init(NTSHELL_SERIAL_READ func_read, 80 NTSHELL_SERIAL_WRITE func_write, void *extobj); 83 81 84 82 /* ntshellタスク */ -
asp3_tinet_ecnl_arm/trunk/ntshell/src/shellif.h
r352 r364 39 39 40 40 #ifdef _MSC_VER 41 #define _CRT_NO_TIME_T42 #define tm msc_tm43 #include <time.h>44 #include <errno.h>45 #include <limits.h>46 #include <stdlib.h>47 #undef tm48 41 #undef NULL 49 42 #endif … … 133 126 #endif 134 127 128 #ifdef __cplusplus 129 extern "C" { 130 #endif 131 135 132 // time.h 136 133 #define CLOCK_REALTIME 0 … … 179 176 int shell_access(const char *path, int mode); 180 177 // signal.h 181 int shell_sigprocmask(int how, const sigset_t * restrict set, sigset_t *restrict old);182 int shell_sigaction(int sig, const struct sigaction * restrict sa, struct sigaction *restrict old);178 int shell_sigprocmask(int how, const sigset_t *__restrict set, sigset_t *__restrict old); 179 int shell_sigaction(int sig, const struct sigaction *__restrict sa, struct sigaction *__restrict old); 183 180 // socket.h 184 181 int shell_socket(int, int, int); 185 182 int shell_connect(int, const struct sockaddr *, socklen_t); 186 ssize_t shell_send(int, const void *, size_t, int);187 183 ssize_t shell_sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t); 188 184 ssize_t shell_sendmsg(int, const struct msghdr *, int); … … 190 186 int shell_listen(int, int); 191 187 int shell_accept(int, struct sockaddr *__restrict, socklen_t *__restrict); 192 ssize_t shell_recv(int, void *, size_t, int);193 188 ssize_t shell_recvfrom(int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict); 194 189 ssize_t shell_recvmsg(int, struct msghdr *, int); … … 263 258 int shell_pipe2(int [2], int); 264 259 int shell_ppoll(struct pollfd *, nfds_t, const struct timespec *,const sigset_t *); 265 int shell_pselect6(int, fd_set * restrict, fd_set *restrict,266 fd_set * restrict, const struct timespec *restrict, const sigset_t *restrict);260 int shell_pselect6(int, fd_set *__restrict, fd_set *__restrict, 261 fd_set *__restrict, const struct timespec *__restrict, const sigset_t *__restrict); 267 262 int shell_setpgid(pid_t, pid_t); 268 263 int shell_setsid(); … … 314 309 void free(void *ptr); 315 310 311 #ifdef __cplusplus 312 } 313 #endif 314 316 315 #endif /* SHELLIF_H */ -
asp3_tinet_ecnl_arm/trunk/ntshell/src/socket_stub.c
r352 r364 42 42 #include <sil.h> 43 43 #include "syssvc/syslog.h" 44 #include <tinet_defs.h> 44 45 #include <tinet_config.h> 46 #include <net/net.h> 47 #include <net/net_endian.h> 45 48 #include <netinet/in.h> 46 49 #include <netinet/in_itron.h> … … 53 56 #include <net/if_var.h> 54 57 #include <netinet/udp_var.h> 58 #include <net/net_buf.h> 55 59 //#include <netinet/tcp_var.h> 56 60 #include <netapp/resolver.h> … … 58 62 #include "ff.h" 59 63 #include "socket_stub.h" 64 #include "kernel_cfg.h" 60 65 61 66 #define SOCKET_TIMEOUT 2000000 … … 181 186 fp->psock->buf_size = 512 + 512; 182 187 fp->psock->buf = malloc(fp->psock->buf_size); 188 #ifdef _DEBUG 189 memset(fp->psock->buf, 0, fp->psock->buf_size); 190 #endif 183 191 T_TCP_CCEP ccep = { 0, fp->psock->buf, 512, &fp->psock->buf[512], 512, (FP)socket_tcp_callback }; 184 192 ret = tcp_cre_cep(cepid, &ccep); … … 279 287 fp->psock->buf_size = 512 + 512; 280 288 fp->psock->buf = malloc(fp->psock->buf_size); 289 #ifdef _DEBUG 290 memset(fp->psock->buf, 0, fp->psock->buf_size); 291 #endif 281 292 T_TCP_CCEP ccep = { 0, fp->psock->buf, 512, &fp->psock->buf[512], 512, (FP)socket_tcp_callback }; 282 293 ret = tcp_cre_cep(cepid, &ccep); … … 298 309 return -EHOSTUNREACH; 299 310 } 300 fp->writable = 1;301 311 break; 302 312 } … … 322 332 } 323 333 324 memcpy( &fp->psock, &lfp->psock, sizeof(fp->psock));334 memcpy(fp->psock, lfp->psock, offsetof(socket_t, buf_size)); 325 335 326 336 ER ret; … … 335 345 fp->psock->buf_size = 512 + 512; 336 346 fp->psock->buf = malloc(fp->psock->buf_size); 347 #ifdef _DEBUG 348 memset(fp->psock->buf, 0, fp->psock->buf_size); 349 #endif 337 350 T_TCP_CCEP ccep = { 0, fp->psock->buf, 512, &fp->psock->buf[512], 512, (FP)socket_tcp_callback }; 338 351 ret = tcp_cre_cep(cepid, &ccep); … … 346 359 else { 347 360 cepid = lfp->psock->cepid; 361 fp->handle = cepid; 348 362 lfp->handle = tmax_tcp_cepid + lfp->psock->repid; 349 363 lfp->psock->cepid = 0; … … 356 370 return -ENOMEM; 357 371 } 358 fp->writable = 1;359 372 struct sockaddr_in *raddr = &fp->psock->raddr4; 360 373 memset(raddr, 0, sizeof(*raddr)); … … 384 397 } 385 398 386 ssize_t shell_send (int fd, const void *buf, size_t len, int flags)399 ssize_t shell_sendto(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t alen) 387 400 { 388 401 SOCKET *fp = fd_to_fp(fd); … … 396 409 switch (fp->psock->type) { 397 410 case SOCK_STREAM: { 398 fp->writable = 0; 411 if ((addr != NULL) || (alen != 0)) { 412 return -EISCONN; 413 } 414 399 415 if (flags & MSG_OOB) { 400 416 ret = tcp_snd_oob(fp->psock->cepid, (void *)buf, len, SOCKET_TIMEOUT); … … 404 420 } 405 421 else { 406 ret = tcp_snd_dat(fp->psock->cepid, (void *)buf, len, SOCKET_TIMEOUT); 407 if (ret < 0) { 408 return -ECOMM; 409 } 410 } 411 break; 412 } 413 case SOCK_DGRAM: { 414 return -EINVAL; 415 } 416 } 417 break; 418 } 419 case AF_INET6: { 420 return -EAFNOSUPPORT; 421 } 422 } 423 424 return ret; 425 } 426 427 ssize_t shell_sendto(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t alen) 428 { 429 SOCKET *fp = fd_to_fp(fd); 430 if (fp == NULL) { 431 return -EBADF; 432 } 433 434 int ret = 0; 435 switch (fp->psock->family) { 436 case AF_INET: { 437 switch (fp->psock->type) { 438 case SOCK_STREAM: { 439 if ((addr != NULL) && (alen != 0)) { 440 return -EINVAL; 441 } 442 443 fp->writable = 0; 444 if (flags & MSG_OOB) { 445 ret = tcp_snd_oob(fp->psock->cepid, (void *)buf, len, SOCKET_TIMEOUT); 446 if (ret < 0) { 447 return -ECOMM; 448 } 449 } 450 else { 451 ret = tcp_snd_dat(fp->psock->cepid, (void *)buf, len, SOCKET_TIMEOUT); 452 if (ret < 0) { 453 return -ECOMM; 454 } 422 for (;;) { 423 ret = tcp_snd_dat(fp->psock->cepid, (void *)buf, len, SOCKET_TIMEOUT); 424 if (ret < 0) { 425 if (ret == E_TMOUT) 426 return -ETIME; 427 return -ECOMM; 428 } 429 len -= ret; 430 if (len <= 0) 431 break; 432 buf = (const void *)&((uint8_t *)buf)[ret]; 433 } 455 434 } 456 435 break; … … 458 437 case SOCK_DGRAM: { 459 438 int sz = alen; 460 if ( sz < 8) {439 if ((addr == NULL) || (sz < 8)) { 461 440 return -EINVAL; 462 441 } … … 465 444 memcpy(raddr, addr, sz); 466 445 T_IPV4EP rep = { ntohl(raddr->sin_addr.s_addr), ntohs(raddr->sin_port) }; 467 fp->writable = 0;468 446 ret = udp_snd_dat(fp->psock->cepid, &rep, (void *)buf, len, 469 (fp->psock->flags & O_NONBLOCK) ? 0: SOCKET_TIMEOUT);447 (fp->psock->flags & O_NONBLOCK) ? TMO_POL : SOCKET_TIMEOUT); 470 448 if (ret < 0) { 471 return -ECOMM;449 return (ret == E_TMOUT) ? -ETIME : -ECOMM; 472 450 } 473 451 break; … … 490 468 } 491 469 492 ssize_t shell_recv (int fd, void *buf, size_t len, int flags)470 ssize_t shell_recvfrom(int fd, void *__restrict buf, size_t len, int flags, struct sockaddr *__restrict addr, socklen_t *__restrict alen) 493 471 { 494 472 SOCKET *fp = fd_to_fp(fd); … … 505 483 ret = tcp_rcv_oob(fp->psock->cepid, buf, len); 506 484 if (ret < 0) { 485 syslog(LOG_ERROR, "tcp_rcv_oob => %d", ret); 507 486 return -ECOMM; 508 487 } 509 488 } 510 489 else { 511 ret = tcp_rcv_dat(fp->psock->cepid, buf, len, TMO_FEVR); 490 int rsz, tmp; 491 if (fp->psock->input == NULL) { 492 ret = wai_sem(SEM_FILEDESC); 493 if (ret < 0) { 494 syslog(LOG_ERROR, "wai_sem => %d", ret); 495 } 496 fp->psock->len = 0; 497 ret = sig_sem(SEM_FILEDESC); 498 if (ret < 0) { 499 syslog(LOG_ERROR, "sig_sem => %d", ret); 500 } 501 ret = tcp_rcv_buf(fp->psock->cepid, &fp->psock->input, TMO_FEVR); 502 if (ret < 0) { 503 syslog(LOG_ERROR, "tcp_rcv_buf => %d", ret); 504 return -ECOMM; 505 } 506 rsz = ret; 507 } 508 else 509 rsz = fp->psock->len; 510 tmp = rsz; 511 if (rsz > len) 512 rsz = len; 513 if (rsz >= 0) { 514 memcpy(buf, fp->psock->input, rsz); 515 ret = wai_sem(SEM_FILEDESC); 516 if (ret < 0) { 517 syslog(LOG_ERROR, "wai_sem => %d", ret); 518 } 519 fp->psock->len = tmp - rsz; 520 ret = sig_sem(SEM_FILEDESC); 521 if (ret < 0) { 522 syslog(LOG_ERROR, "sig_sem => %d", ret); 523 } 524 if (tmp - rsz == 0) { 525 fp->psock->input = NULL; 526 } 527 else 528 fp->psock->input = (void *)&((uint8_t *)fp->psock->input)[rsz]; 529 ret = tcp_rel_buf(fp->psock->cepid, rsz); 530 if ((ret != E_OBJ) && (ret < 0)) { 531 syslog(LOG_ERROR, "tcp_rel_buf => %d", ret); 532 //return -ECOMM; 533 } 534 } 535 ret = rsz; 536 } 537 break; 538 } 539 case SOCK_DGRAM: { 540 struct sockaddr_in *raddr = &fp->psock->raddr4; 541 int rsz; 542 ret = wai_sem(SEM_FILEDESC); 543 if (ret < 0) { 544 syslog(LOG_ERROR, "wai_sem => %d", ret); 545 } 546 T_NET_BUF *input = fp->psock->input; 547 if (input == NULL) { 548 ret = sig_sem(SEM_FILEDESC); 512 549 if (ret < 0) { 513 return -ECOMM; 514 } 515 } 516 break; 517 } 518 case SOCK_DGRAM: { 519 T_IPV4EP rep = { 0, 0 }; 520 ret = udp_rcv_dat(fp->psock->cepid, &rep, buf, len, (fp->psock->flags & O_NONBLOCK) ? 0 : TMO_FEVR); 521 if (ret < 0) { 522 return -ECOMM; 523 } 524 } 525 } 526 break; 527 } 528 case AF_INET6: { 529 return -EAFNOSUPPORT; 530 } 531 } 532 533 return ret; 534 } 535 536 ssize_t shell_recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr *__restrict addr, socklen_t *__restrict alen) 537 { 538 SOCKET *fp = fd_to_fp(fd); 539 if (fp == NULL) { 540 return -EBADF; 541 } 542 543 int ret = 0; 544 switch (fp->psock->family) { 545 case AF_INET: { 546 switch (fp->psock->type) { 547 case SOCK_STREAM: { 548 if (flags & MSG_OOB) { 549 ret = tcp_rcv_oob(fp->psock->cepid, buf, len); 550 syslog(LOG_ERROR, "sig_sem => %d", ret); 551 } 552 553 T_IPV4EP rep = { 0, 0 }; 554 ret = udp_rcv_dat(fp->psock->cepid, &rep, buf, len, 555 (fp->psock->flags & O_NONBLOCK) ? TMO_POL : SOCKET_TIMEOUT); 550 556 if (ret < 0) { 551 return -ECOMM; 557 syslog(LOG_ERROR, "udp_rcv_buf => %d", ret); 558 return (ret == E_TMOUT) ? -ETIME : -ECOMM; 559 } 560 rsz = ret; 561 if ((addr != NULL) && (alen != NULL)) { 562 ret = wai_sem(SEM_FILEDESC); 563 if (ret < 0) { 564 syslog(LOG_ERROR, "wai_sem => %d", ret); 565 } 566 int sz = *alen; 567 memset(raddr, 0, sizeof(fp->psock->raddr4)); 568 raddr->sin_family = AF_INET; 569 raddr->sin_port = htons(rep.portno); 570 raddr->sin_addr.s_addr = htonl(rep.ipaddr); 571 if (sz > sizeof(fp->psock->raddr4)) 572 sz = sizeof(fp->psock->raddr4); 573 memcpy(addr, raddr, sz); 574 *alen = sz; 575 ret = sig_sem(SEM_FILEDESC); 576 if (ret < 0) { 577 syslog(LOG_ERROR, "sig_sem => %d", ret); 578 } 552 579 } 553 580 } 554 581 else { 555 ret = tcp_rcv_dat(fp->psock->cepid, buf, len, TMO_FEVR); 582 rsz = fp->psock->len; 583 void *pbuf = fp->psock->buf; 584 fp->psock->input = NULL; 585 fp->psock->len = 0; 586 fp->psock->buf = NULL; 587 if ((addr != NULL) && (alen != NULL)) { 588 int sz = *alen; 589 if (sz > sizeof(fp->psock->raddr4)) 590 sz = sizeof(fp->psock->raddr4); 591 memcpy(addr, raddr, sz); 592 *alen = sz; 593 } 594 ret = sig_sem(SEM_FILEDESC); 556 595 if (ret < 0) { 557 return -ECOMM; 558 } 559 } 560 break; 561 } 562 case SOCK_DGRAM: { 563 T_IPV4EP rep = { 0, 0 }; 564 ret = udp_rcv_dat(fp->psock->cepid, &rep, buf, len, TMO_FEVR); 565 if (ret < 0) { 566 return -ECOMM; 567 } 568 int sz = *alen; 569 struct sockaddr_in raddr; 570 memset(&raddr, 0, sizeof(raddr)); 571 raddr.sin_family = AF_INET; 572 raddr.sin_port = htons(rep.portno); 573 raddr.sin_addr.s_addr = htonl(rep.ipaddr); 574 if (sz > sizeof(raddr)) 575 sz = sizeof(raddr); 576 memcpy(addr, &raddr, sz); 596 syslog(LOG_ERROR, "sig_sem => %d", ret); 597 } 598 if (rsz > len) 599 rsz = len; 600 memcpy(buf, pbuf, rsz); 601 ret = rel_net_buf(input); 602 if (ret < 0) { 603 syslog(LOG_ERROR, "rel_net_buf => %d", ret); 604 //return -ECOMM; 605 } 606 } 607 ret = rsz; 577 608 } 578 609 } … … 830 861 int tcp_fd_close(struct _IO_FILE *fp) 831 862 { 832 ER ret; 833 834 free(fp->psock->buf); 835 fp->psock->buf = NULL; 863 ER ret, ret2; 836 864 837 865 switch (fp->psock->family) { … … 844 872 } 845 873 ret = tcp_cls_cep(cepid, (fp->psock->repid != 0) ? 0 : SOCKET_TIMEOUT); 846 if (ret < 0) { 847 //return -1; 848 } 849 ret = tcp_del_cep(cepid); 874 ret2 = tcp_del_cep(cepid); 875 free(fp->psock->buf); 876 fp->psock->buf = NULL; 850 877 delete_tcp_fd(cepid); 851 878 delete_id(tcp_cepid_table, tcp_cepid_table_count, cepid); 852 if ( ret < 0) {853 return -EINVAL;879 if ((ret < 0) || (ret2 < 0)) { 880 return (ret == E_TMOUT) ? -ETIME : -EINVAL; 854 881 } 855 882 } … … 857 884 ID repid = fp->psock->repid; 858 885 ret = tcp_del_rep(repid); 886 free(fp->psock->buf); 887 fp->psock->buf = NULL; 859 888 delete_tcp_fd(tmax_tcp_cepid + repid); 860 889 delete_id(tcp_repid_table, tcp_repid_table_count, repid); … … 864 893 } 865 894 else { 895 free(fp->psock->buf); 896 fp->psock->buf = NULL; 866 897 return -EINVAL; 867 898 } … … 878 909 size_t tcp_fd_read(struct _IO_FILE *fp, unsigned char *dst, size_t dstsz) 879 910 { 880 return shell_recv (fp->fd, dst, dstsz, 0);911 return shell_recvfrom(fp->fd, dst, dstsz, 0, NULL, NULL); 881 912 } 882 913 883 914 size_t tcp_fd_write(struct _IO_FILE *fp, const unsigned char *src, size_t srcsz) 884 915 { 885 return shell_send (fp->fd, src, srcsz, 0);916 return shell_sendto(fp->fd, src, srcsz, 0, NULL, 0); 886 917 } 887 918 … … 901 932 ID cepid; 902 933 903 free(fp->psock->buf);904 fp->psock->buf = NULL;905 906 934 switch (fp->psock->family) { 907 935 case AF_INET: { 908 936 cepid = fp->psock->cepid; 909 937 ret = udp_del_cep(cepid); 938 //free(fp->psock->buf); 939 //fp->psock->buf = NULL; 910 940 delete_udp_fd(cepid); 911 941 delete_id(udp_cepid_table, udp_cepid_table_count, cepid); … … 925 955 size_t udp_fd_read(struct _IO_FILE *fp, unsigned char *dst, size_t dstsz) 926 956 { 927 return shell_recv (fp->fd, dst, dstsz, 0);957 return shell_recvfrom(fp->fd, dst, dstsz, 0, NULL, NULL); 928 958 } 929 959 930 960 size_t udp_fd_write(struct _IO_FILE *fp, const unsigned char *src, size_t srcsz) 931 961 { 932 return shell_send (fp->fd, src, srcsz, 0);962 return shell_sendto(fp->fd, src, srcsz, 0, NULL, 0); 933 963 } 934 964 -
asp3_tinet_ecnl_arm/trunk/ntshell/src/socket_stub.h
r352 r364 99 99 int buf_size; 100 100 unsigned char *buf; 101 void *input; 102 int len; 101 103 } socket_t; 102 104 -
asp3_tinet_ecnl_arm/trunk/ntshell/src/syscall.c
r352 r364 201 201 202 202 long SYS_futex() { 203 int futex(int *uaddr, int op, int val, const struct timespec *timeout, int *uaddr2, int val3); 203 204 return no_implement("futex\n"); 204 205 } … … 309 310 310 311 long SYS_recv(long a, long b, long c, long d) { 311 return shell_recv ((int)a, (void *)b, (size_t)c, (int)d);312 return shell_recvfrom((int)a, (void *)b, (size_t)c, (int)d, NULL, NULL); 312 313 } 313 314 314 315 long SYS_recvfrom(long a, long b, long c, long d, long e, long f) { 315 if (a == 0) 316 return shell_recv(a, (void *)b, (size_t)c, (int)d); 317 else 318 return shell_recvfrom(a, (void *)b, (size_t)c, (int)d, (struct sockaddr *)e, (socklen_t *)f); 316 return shell_recvfrom(a, (void *)b, (size_t)c, (int)d, (struct sockaddr *)e, (socklen_t *)f); 319 317 } 320 318 … … 344 342 345 343 long SYS_send(long a, long b, long c, long d) { 346 return shell_send ((int)a, (const void *)b, (size_t)c, (int)d);344 return shell_sendto((int)a, (const void *)b, (size_t)c, (int)d, NULL, 0); 347 345 } 348 346 … … 352 350 353 351 long SYS_sendto(long a, long b, long c, long d, long e, long f) { 354 if (a == 0) 355 return shell_send(a, (const void *)b, (size_t)c, (int)d); 356 else 357 return shell_sendto(a, (const void *)b, (size_t)c, (int)d, (const struct sockaddr *)e, (socklen_t)f); 352 return shell_sendto(a, (const void *)b, (size_t)c, (int)d, (const struct sockaddr *)e, (socklen_t)f); 358 353 } 359 354 … … 422 417 } 423 418 419 long SYS_dup() 420 { 421 return no_implement("dup\n"); 422 } 423 424 long SYS_dup2() 425 { 426 return no_implement("dup2\n"); 427 } 428 429 long SYS_pipe() 430 { 431 return no_implement("pipe\n"); 432 } 433 434 long SYS_readlink() 435 { 436 return no_implement("readlink\n"); 437 } 438 439 long SYS_symlink() 440 { 441 return no_implement("symlink\n"); 442 } 443 444 long SYS_umask() 445 { 446 return no_implement("umask\n"); 447 } 448 449 long SYS_execve() 450 { 451 return no_implement("execve\n"); 452 } 453 454 long SYS_fork() 455 { 456 return no_implement("fork\n"); 457 } 458 459 long SYS_wait4() 460 { 461 return no_implement("wait4\n"); 462 } 463 464 long SYS_socketpair() 465 { 466 return no_implement("socketpair\n"); 467 } 468 469 long SYS_flock() 470 { 471 return no_implement("flock\n"); 472 } 473 424 474 long ARM_SYS_cacheflush() { 425 475 flash_access_cache_control();
Note:
See TracChangeset
for help on using the changeset viewer.