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_rx/trunk/bnep_bridge/src/main.c

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