Changeset 359 for asp3_tinet_ecnl_rx/trunk/ntshell
- Timestamp:
- Jun 20, 2018, 7:59:22 PM (6 years ago)
- Location:
- asp3_tinet_ecnl_rx/trunk/ntshell
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
asp3_tinet_ecnl_rx/trunk/ntshell/fatfs/ffarch.c
r337 r359 54 54 #include "mbed_api.h" 55 55 56 //extern ntstdio_t ntstdio; 56 extern ntstdio_t ntstdio; 57 58 enum ffarch_state_t { 59 FFS_IDLE, 60 FFS_RETRY_WAIT, 61 }; 62 63 enum ffarch_state_t ffarch_state; 64 volatile int ffarch_timer; 65 int ffarch_retry_count; 66 uint8_t mmc_rspi_prev_status; 67 68 static void ffarch_initialize(); 69 70 /* 71 * FatFSタスク 72 */ 73 void ffarch_task(intptr_t exinf) 74 { 75 ER ret, ret2; 76 SYSTIM prev, now; 77 int timer; 78 79 ffarch_initialize(); 80 81 ret2 = get_tim(&now); 82 if (ret2 != E_OK){ 83 ntstdio_printf(&ntstdio, "[ffarch] get_tim error: %s", 84 itron_strerror(ret2)); 85 return; 86 } 87 88 for(;;){ 89 prev = now; 90 91 /* タイマー取得 */ 92 timer = ffarch_get_timer(); 93 94 /* 待ち */ 95 ret = tslp_tsk(timer); 96 if ((ret != E_OK) && (ret != E_TMOUT)) { 97 ntstdio_printf(&ntstdio, "[ffarch] tslp_tsk error: %s %d", 98 itron_strerror(ret), timer); 99 break; 100 } 101 102 ret2 = get_tim(&now); 103 if (ret2 != E_OK) { 104 ntstdio_printf(&ntstdio, "[ffarch] get_tim error: %s", 105 itron_strerror(ret2)); 106 break; 107 } 108 109 /* 時間経過 */ 110 int elapse = now - prev; 111 ffarch_progress(elapse); 112 113 /* タイムアウト処理 */ 114 ffarch_timeout(); 115 } 116 } 57 117 58 118 FATFS RomDisk; … … 88 148 //sdfs_init(&sdfs, P8_5, P8_6, P8_3, P8_4, "sd"); 89 149 90 result = SD_begin() ? 0 : -1; 91 if (result == 0) { 92 printf("SD card (1:) OK!\n"); 150 ffarch_state = FFS_IDLE; 151 ffarch_timer = 0; 152 ffarch_retry_count = 3; 153 mmc_rspi_prev_status = STA_NODISK; 154 155 ffarch_timeout(); 156 157 act_tsk(FFARCH_TASK); 158 159 if (romdisk_init()) { 160 ntstdio_printf(&ntstdio, "ROM disk (0:) OK!\n"); 93 161 } 94 162 else { 95 printf("SD card (1:) NG!\n"); 96 } 163 ntstdio_printf(&ntstdio, "ROM disk (0:) NG!\n"); 164 } 165 166 serial_ctl_por(SIO_PORTID, IOCTL_FCSND | IOCTL_FCRCV); 167 } 168 169 void ffarch_initialize() 170 { 97 171 sta_cyc(MMC_RSPI_CYC); 98 99 if (romdisk_init())100 result = 0;101 102 if (result == 0) {103 printf("ROM disk (0:) OK!\n");104 }105 else {106 printf("ROM disk (0:) NG!\n");107 }108 109 /* uploadディレクトリを作成しておく */110 f_mkdir("1:/upload");111 112 serial_ctl_por(SIO_PORTID, IOCTL_FCSND | IOCTL_FCRCV);113 114 return result;115 172 } 116 173 … … 216 273 } 217 274 return RES_PARERR; 275 } 276 277 void mmc_rspi_status_changed(DSTATUS newst) 278 { 279 if (ffarch_state == FFS_IDLE) { 280 mmc_rspi_prev_status = mmc_rspi_status(); 281 ffarch_timer = 0; 282 wup_tsk(FFARCH_TASK); 283 } 284 } 285 286 int ffarch_get_timer() 287 { 288 return ffarch_timer; 289 } 290 291 void ffarch_progress(int elapse) 292 { 293 if (ffarch_timer != TMO_FEVR) { 294 ffarch_timer -= elapse; 295 if (ffarch_timer < 0) { 296 ffarch_timer = 0; 297 } 298 } 299 } 300 301 void ffarch_timeout() 302 { 303 if (ffarch_timer != 0) 304 return; 305 306 switch (ffarch_state) { 307 case FFS_RETRY_WAIT: 308 if (ffarch_retry_count == 0) { 309 ntstdio_printf(&ntstdio, "SD card (1:) initialize tired...\n"); 310 311 ffarch_state = FFS_IDLE; 312 ffarch_timer = TMO_FEVR; 313 ffarch_retry_count = 3; 314 break; 315 } 316 ffarch_retry_count--; 317 //goto case FFS_IDLE; 318 case FFS_IDLE: 319 /* SDカードが入れられた場合 */ 320 if (((mmc_rspi_prev_status & STA_NODISK) != 0) && ((mmc_rspi_status() & STA_NODISK) == 0)) { 321 ntstdio_printf(&ntstdio, "SD card initializing ...\n"); 322 323 Sd.FatFs.fs_type = 0; 324 if (SD_begin()) { 325 ntstdio_printf(&ntstdio, "SD card (1:) OK!\n"); 326 327 /* uploadディレクトリを作成しておく */ 328 f_mkdir("1:/upload"); 329 330 ffarch_state = FFS_IDLE; 331 ffarch_timer = TMO_FEVR; 332 ffarch_retry_count = 3; 333 } 334 else { 335 ntstdio_printf(&ntstdio, "SD card (1:) NG!\n"); 336 ffarch_state = FFS_RETRY_WAIT; 337 ffarch_timer = 1000 * 1000; 338 } 339 } 340 /* SDカードが抜かれた場合 */ 341 else if (((mmc_rspi_prev_status & STA_NODISK) == 0) && ((mmc_rspi_status() & STA_NODISK) != 0)) { 342 ntstdio_printf(&ntstdio, "SD card unmount\n"); 343 344 f_mount(&Sd.FatFs, "1:", 0); 345 ffarch_state = FFS_IDLE; 346 ffarch_timer = TMO_FEVR; 347 ffarch_retry_count = 3; 348 } 349 mmc_rspi_prev_status = mmc_rspi_status(); 350 break; 351 } 218 352 } 219 353 -
asp3_tinet_ecnl_rx/trunk/ntshell/fatfs/ffarch.cfg
r337 r359 38 38 #include "ffarch.h" 39 39 40 CRE_TSK(FFARCH_TASK, { TA_NULL, 0, ffarch_task, FFARCH_PRIORITY, FFARCH_STACK_SIZE, NULL }); 40 41 INCLUDE("mmc_rspi.cfg"); 41 42 -
asp3_tinet_ecnl_rx/trunk/ntshell/fatfs/ffarch.h
r337 r359 38 38 #define _FFARCH_H_ 39 39 40 int ffarch_init(); 40 #define FFARCH_PRIORITY 5 41 #define FFARCH_STACK_SIZE 512 42 43 void ffarch_init(); 44 void ffarch_task(intptr_t exinf); 45 int ffarch_get_timer(); 46 void ffarch_progress(int elapse); 47 void ffarch_timeout(); 48 41 49 void sdfs_cychdr(intptr_t exinf); 42 50 -
asp3_tinet_ecnl_rx/trunk/ntshell/fatfs/mmc_rspi.c
r343 r359 201 201 ena_int(INTNO_MMC_RSPI_SPII); 202 202 203 sta_cyc(MMC_RSPI_CYC);203 /*sta_cyc(MMC_RSPI_CYC);*/ 204 204 } 205 205 … … 211 211 void power_off(void) /* Disable MMC/SDC interface */ 212 212 { 213 stp_cyc(MMC_RSPI_CYC);213 /*stp_cyc(MMC_RSPI_CYC);*/ 214 214 215 215 dis_int(INTNO_MMC_RSPI_SPRI); … … 745 745 else /* Socket empty */ 746 746 s |= (STA_NODISK | STA_NOINIT); 747 Stat = s; 747 748 if (Stat != s) { 749 mmc_rspi_status_changed(s); 750 Stat = s; 751 } 748 752 } 749 753 -
asp3_tinet_ecnl_rx/trunk/ntshell/fatfs/mmc_rspi.h
r337 r359 67 67 #endif 68 68 69 extern void mmc_rspi_spri_handler(void); 70 extern void mmc_rspi_spti_handler(void); 71 extern void mmc_rspi_spii_handler(void); 72 extern void mmc_rspi_cychdr(intptr_t exinf); 69 void mmc_rspi_spri_handler(void); 70 void mmc_rspi_spti_handler(void); 71 void mmc_rspi_spii_handler(void); 72 void mmc_rspi_cychdr(intptr_t exinf); 73 void mmc_rspi_status_changed(DSTATUS newst); 73 74 74 75 #endif /* _MMC_RSPI_H_ */ -
asp3_tinet_ecnl_rx/trunk/ntshell/src/fdtable.c
r337 r359 400 400 FD_SET(fd, (fd_set *)&flgptn); 401 401 } 402 if (rpor.wricnt < rpor.wbufsz) {402 if (rpor.wricnt != 0) { 403 403 if (fp->writeevt_w == fp->writeevt_r) fp->writeevt_w++; 404 404 … … 428 428 FD_SET(fd, (fd_set *)flgptn); 429 429 } 430 if (rpor.wricnt < rpor.wbufsz) {430 if (rpor.wricnt != 0) { 431 431 if (fp->writeevt_w == fp->writeevt_r) fp->writeevt_w++; 432 432 -
asp3_tinet_ecnl_rx/trunk/ntshell/src/net_misc.c
r340 r359 33 33 * の責任を負わない. 34 34 * 35 * @(#) $Id : net_misc.c 1497 2018-04-13 00:04:30Z coas-nagasima$35 * @(#) $Id$ 36 36 */ 37 37 … … 60 60 #include "kernel_cfg.h" 61 61 #include "tinet_cfg.h" 62 #include "util/ntstdio.h" 63 64 extern ntstdio_t ntstdio; 62 65 63 66 T_DHCP4_CLI_CONTEXT *dhcp4_cli_initialize(ID tskid, ID cepid); … … 94 97 95 98 get_tid(&nc->tskid); 96 syslog(LOG_NOTICE, "[NET MISC:%d,%d] started.", nc->tskid, (ID)exinf);99 ntstdio_printf(&ntstdio, "[NET MISC:%d,%d] started.", nc->tskid, (ID)exinf); 97 100 98 101 /* 初期化 */ … … 102 105 ret = get_tim(&time); 103 106 if (ret != E_OK) { 104 syslog(LOG_NOTICE, "[NET MISC,%d] get_tim error: %7lu,%s",107 ntstdio_printf(&ntstdio, "[NET MISC,%d] get_tim error: %7lu,%s", 105 108 nc->cepid, time / SYSTIM_HZ, itron_strerror(ret)); 106 109 return; … … 116 119 error = tslp_tsk(timer); 117 120 if ((error != E_OK) && (error != E_TMOUT)) { 118 syslog(LOG_NOTICE, "[NET MISC,%d] tslp_tsk error: %s %d",121 ntstdio_printf(&ntstdio, "[NET MISC,%d] tslp_tsk error: %s %d", 119 122 nc->cepid, itron_strerror(error), timer); 120 123 break; … … 123 126 ret = get_tim(&time); 124 127 if (ret != E_OK) { 125 syslog(LOG_NOTICE, "[NET MISC,%d] get_tim error: %s",128 ntstdio_printf(&ntstdio, "[NET MISC,%d] get_tim error: %s", 126 129 nc->cepid, itron_strerror(ret)); 127 130 break; -
asp3_tinet_ecnl_rx/trunk/ntshell/src/net_misc.cfg
r340 r359 33 33 * の責任を負わない. 34 34 * 35 * @(#) $Id : net_misc.cfg 1497 2018-04-13 00:04:30Z coas-nagasima$35 * @(#) $Id$ 36 36 */ 37 37 -
asp3_tinet_ecnl_rx/trunk/ntshell/src/net_misc.h
r340 r359 33 33 * の責任を負わない. 34 34 * 35 * @(#) $Id : net_misc.h 1497 2018-04-13 00:04:30Z coas-nagasima$35 * @(#) $Id$ 36 36 */ 37 37 -
asp3_tinet_ecnl_rx/trunk/ntshell/src/ntp_cli.c
r340 r359 33 33 * の責任を負わない. 34 34 * 35 * @(#) $Id : ntp_cli.c 1496 2018-04-12 11:59:40Z coas-nagasima$35 * @(#) $Id$ 36 36 */ 37 37 … … 50 50 #include <t_syslog.h> 51 51 #include "kernel_cfg.h" 52 #include "util/ntstdio.h" 53 54 extern ntstdio_t ntstdio; 52 55 53 56 #endif /* of #if defined(TARGET_KERNEL_ASP) */ … … 276 279 } 277 280 278 syslog(LOG_NOTICE, "[NTP CLI,%d] recv time: %s .%09u",281 ntstdio_printf(&ntstdio, "[NTP CLI,%d] recv time: %s .%09u\n", 279 282 nc->cepid, nc->buf, tp.tv_nsec); 280 283 } … … 308 311 line = lookup_ipaddr(&nc->ipaddr6, NTP_SRV_URL, API_PROTO_IPV4); 309 312 if (line == NULL || !in6_is_addr_ipv4mapped(&nc->ipaddr6)) { 310 syslog(LOG_NOTICE, "[NTP CLI,%d] sleep %d.%03u[s], unknown host.",313 ntstdio_printf(&ntstdio, "[NTP CLI,%d] sleep %d.%03u[s], unknown host.", 311 314 nc->cepid, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ); 312 315 nc->timer = SLP_ITV; … … 316 319 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 317 320 if ((line = lookup_ipaddr(&nc->snd_rmt.ipaddr, NTP_SRV_URL, DEFAULT_API_PROTO)) == NULL) { 318 syslog(LOG_NOTICE, "[NTP CLI,%d] sleep %d.%03u[s], unknown host.",321 ntstdio_printf(&ntstdio, "[NTP CLI,%d] sleep %d.%03u[s], unknown host.", 319 322 nc->cepid, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ); 320 323 nc->timer = SLP_ITV; … … 420 423 421 424 if ((error = udp_snd_dat(nc->cepid, &nc->snd_rmt, ntp, len, TMO_NBLK)) != E_WBLK) { 422 syslog(LOG_NOTICE, "[NTP CLI,%d] udp_snd_dat error: %s",425 ntstdio_printf(&ntstdio, "[NTP CLI,%d] udp_snd_dat error: %s", 423 426 nc->cepid, itron_strerror(error)); 424 427 return error; … … 438 441 ret = get_tim(&time); 439 442 if (ret != E_OK) { 440 syslog(LOG_NOTICE, "[NTP CLI,%d] get_tim error: %s",443 ntstdio_printf(&ntstdio, "[NTP CLI,%d] get_tim error: %s", 441 444 nc->cepid, itron_strerror(ret)); 442 445 tp->tv_sec = 0; … … 458 461 ret = set_tim(time); 459 462 if (ret != E_OK) { 460 syslog(LOG_NOTICE, "[NTP CLI,%d] set_tim error: %s",463 ntstdio_printf(&ntstdio, "[NTP CLI,%d] set_tim error: %s", 461 464 nc->cepid, itron_strerror(ret)); 462 465 } … … 476 479 if (len < 0 && len != E_RLWAI) { 477 480 /* E_RLWAI 以外で、0 以下の場合は、エラーを意味している。*/ 478 syslog(LOG_NOTICE, "[NTP CLI,%d] callback error: %s, fncd: %s", nc->cepid,481 ntstdio_printf(&ntstdio, "[NTP CLI,%d] callback error: %s, fncd: %s", nc->cepid, 479 482 itron_strerror(len), in_strtfn(fncd)); 480 483 } … … 483 486 if ((len = udp_rcv_dat(nc->cepid, &nc->rcv_rmt, &nc->ntp_msg, len, TMO_POL)) < 0) 484 487 { 485 syslog(LOG_NOTICE, "[NTP CLI,%d] udp_rcv_dat error: %s", nc->cepid,488 ntstdio_printf(&ntstdio, "[NTP CLI,%d] udp_rcv_dat error: %s", nc->cepid, 486 489 itron_strerror(len)); 487 490 } … … 515 518 516 519 get_tid(&nc->tskid); 517 syslog(LOG_NOTICE, "[NTP CLI:%d,%d] started.", nc->tskid, (ID)exinf);520 ntstdio_printf(&ntstdio, "[NTP CLI:%d,%d] started.", nc->tskid, (ID)exinf); 518 521 519 522 /* 初期化 */ … … 522 525 ret = get_tim(&time); 523 526 if (ret != E_OK) { 524 syslog(LOG_NOTICE, "[NTP CLI,%d] get_tim error: %7lu,%s",527 ntstdio_printf(&ntstdio, "[NTP CLI,%d] get_tim error: %7lu,%s", 525 528 nc->cepid, time / SYSTIM_HZ, itron_strerror(ret)); 526 529 return; … … 536 539 error = tslp_tsk(timer); 537 540 if ((error != E_OK) && (error != E_TMOUT)) { 538 syslog(LOG_NOTICE, "[NTP CLI,%d] tslp_tsk error: %s %d",541 ntstdio_printf(&ntstdio, "[NTP CLI,%d] tslp_tsk error: %s %d", 539 542 nc->cepid, itron_strerror(error), timer); 540 543 break; … … 543 546 ret = get_tim(&time); 544 547 if (ret != E_OK) { 545 syslog(LOG_NOTICE, "[NTP CLI,%d] get_tim error: %s",548 ntstdio_printf(&ntstdio, "[NTP CLI,%d] get_tim error: %s", 546 549 nc->cepid, itron_strerror(ret)); 547 550 break; -
asp3_tinet_ecnl_rx/trunk/ntshell/src/ntp_cli.cfg
r340 r359 33 33 * の責任を負わない. 34 34 * 35 * @(#) $Id : ntp_cli.cfg 1496 2018-04-12 11:59:40Z coas-nagasima$35 * @(#) $Id$ 36 36 */ 37 37 -
asp3_tinet_ecnl_rx/trunk/ntshell/src/ntp_cli.h
r340 r359 33 33 * の責任を負わない. 34 34 * 35 * @(#) $Id : ntp_cli.h 1496 2018-04-12 11:59:40Z coas-nagasima$35 * @(#) $Id$ 36 36 */ 37 37 -
asp3_tinet_ecnl_rx/trunk/ntshell/src/syscall.c
r349 r359 33 33 * の責任を負わない. 34 34 * 35 * @(#) $Id : syscall.c 1530 2018-04-27 04:00:17Z coas-nagasima$35 * @(#) $Id$ 36 36 */ 37 37 #include "bits/syscall.h" -
asp3_tinet_ecnl_rx/trunk/ntshell/src/tinet_ntp_cli.cfg
r340 r359 29 29 * 接的または間接的に生じたいかなる損害に関しても,その責任を負わない. 30 30 * 31 * @(#) $Id : tinet_ntp_cli.cfg 1291 2017-07-20 02:51:05Z coas-nagasima$31 * @(#) $Id$ 32 32 */ 33 33
Note:
See TracChangeset
for help on using the changeset viewer.