Ignore:
Timestamp:
Feb 1, 2019, 9:57:09 PM (5 years ago)
Author:
coas-nagasima
Message:

TINETとSocket APIなどを更新

File:
1 edited

Legend:

Unmodified
Added
Removed
  • asp3_tinet_ecnl_arm/trunk/bnep_bridge/src/main.c

    r359 r364  
    118118static void main_timeout();
    119119
     120extern int ntshell_exit;
     121
    120122int uart_read(char *buf, int cnt, void *extobj)
    121123{
    122         return serial_rea_dat(SIO_PORTID, (char *)buf, cnt);
     124        struct main_t *obj = (struct main_t *)extobj;
     125        int result;
     126        ER ret;
     127        int timer;
     128
     129        obj->prev = obj->now;
     130
     131        /* タイマー取得 */
     132        timer = main_get_timer();
     133
     134        /* 待ち */
     135        ret = serial_trea_dat(SIO_PORTID, buf, cnt, timer);
     136        if ((ret < 0) && (ret != E_OK) && (ret != E_TMOUT)) {
     137                syslog(LOG_NOTICE, "tslp_tsk ret: %s %d", itron_strerror(ret), timer);
     138                ntshell_exit = 1;
     139                return -1;
     140        }
     141        result = (int)ret;
     142
     143        ret = get_tim(&obj->now);
     144        if (ret != E_OK) {
     145                syslog(LOG_NOTICE, "get_tim ret: %s", itron_strerror(ret));
     146                ntshell_exit = 1;
     147                return -1;
     148        }
     149
     150                        /* 時間経過 */
     151        int elapse = obj->now - obj->prev;
     152        main_progress(elapse);
     153
     154        /* タイムアウト処理 */
     155        main_timeout();
     156
     157        return result;
    123158}
    124159
     
    126161{
    127162        return serial_wri_dat(SIO_PORTID, buf, cnt);
    128 }
    129 
    130 unsigned char ntstdio_xi(struct ntstdio_t *handle)
    131 {
    132         char buf[1];
    133         if(serial_rea_dat(SIO_PORTID, buf, 1) != 1)
    134                 return -EIO;
    135         return buf[0];
    136 }
    137 
    138 void ntstdio_xo(struct ntstdio_t *handle, unsigned char c)
    139 {
    140         char buf[1];
    141         buf[0] = c;
    142         serial_wri_dat(SIO_PORTID, buf, 1);
    143163}
    144164
     
    155175        main_initialize();
    156176
    157         ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, NULL);
     177        ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, &main_obj);
    158178        ntshell_set_prompt(&ntshell, "NTShell>");
    159179        ntshell_execute(&ntshell);
     
    173193        ER ret;
    174194
    175         ntshell_task_init();
     195#ifdef TOPPERS_OMIT_TECS
     196        serial_opn_por(SIO_PORTID);
     197#endif
     198        serial_ctl_por(SIO_PORTID, IOCTL_FCSND | IOCTL_FCRCV);
     199
     200        ntshell_task_init(uart_read, uart_write, &main_obj);
    176201
    177202        main_obj.timer = TMO_FEVR;
Note: See TracChangeset for help on using the changeset viewer.