This is the mail archive of the ecos-bugs@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug 1001873] Patches to upgrade lwip to 1.4.1


Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001873

--- Comment #48 from Oleg Uzenkov <o.uzenkov@unicore.co.ua> ---
Ilija,

(In reply to comment #47)
> Oleg
> 
> (In reply to comment #46)
> 
> Thank you for your report. I have some additional questions.
> 
> > Hi Ilija,
> > 
> 
> [SNIP]
> 
> > 
> > (This is just a snipet from the log.)
> > Apparently, it meant that I did not receive anything from GPRS modem through
> > the serial port. That happened quite often, however, successful connection
> > did happen also.
> 
> What was your serial line setting: baud rate, (hardware) handshaking ?

Serial settings: 9600, 8N1 (no hw/sw control)

> 
> > 
> > But when I started using GPRS VPN service from my cellular network provider
> > this problem has not shown up yet. I have tested it several times and there
> > was always  a successfull connection. So I believe now, the problem was
> > related to the quality of service and not to the PPP (1.4.1) implementation.
> 
> Can you try different locations?

I tired two providers. 

> 
> Ilija

Another problem came up:
Sometimes when ppp connection gets terminated (it can happen all of a sudden,
not sure why) and the stack is then trying to reconnect (i have a state machine
logic, see below), it cannot open serial port (pppOpen, pd is negative, see
below) again after it has been closed with pppClose. Please note, sometimes it
can reopen serial port, but not always. The lwip stack is in simple mode (i.e.
NO_SYS=1).

With 1.3.2 version of ppp I do not have these problems.

Here is the code snippet with the logic:
  void ppp_service::_thread_func (cyg_addrword_t p)
  {
    int err;
    cyg_uint32 len;
    cyg_uint32 cfg_data;
    int pd = -1;
    sio_fd_t sd;
    chat_t chat;

    int count;
    static const cyg_uint32 buf_length = 128;
    u8_t rxbuf[buf_length];

    ppp_service * srv = reinterpret_cast<ppp_service *> (p);

    /*configure serial port */
    err = cyg_io_lookup (SERIAL_PORT, &sd);
    LOG_ASSERT (err == ENOERR);
    LOG_ASSERT (sd != NULL);

    /* read port configuration */
    cyg_serial_info_t port_info;
    cyg_uint32 port_info_len = sizeof (port_info);
    err = cyg_io_get_config (sd,
              CYG_IO_GET_CONFIG_SERIAL_INFO,
              &port_info,
              &port_info_len);
    LOG_ASSERT (err == ENOERR);

    /* update port configuration */
    port_info_len = sizeof (port_info);

    port_info.baud = CYGNUM_SERIAL_BAUD_9600;
    port_info.stop = CYGNUM_SERIAL_STOP_1;
    port_info.parity = CYGNUM_SERIAL_PARITY_NONE;
    port_info.word_length = CYGNUM_SERIAL_WORD_LENGTH_8;

    err = cyg_io_set_config (sd,
              CYG_IO_SET_CONFIG_SERIAL_INFO,
              &port_info,
              &port_info_len);
    LOG_ASSERT (err == ENOERR);

    /**
     * configure cyg_io_read to be non-blocking
     * since blocking cannot be used in interrupts
     */
    cfg_data = 0;
    len = sizeof(cfg_data);
    err = cyg_io_set_config (sd, CYG_IO_SET_CONFIG_READ_BLOCKING, &cfg_data,
&len);
    LOG_ASSERT (err == ENOERR);


    while (1) {
      switch (srv->_init_state) {
        case CHAT_INIT:
          chat = chat_new(sd, chat_items, CHAT_TIMEOUT, srv->_chat_cb,
                          srv->_chat_send_cb, static_cast<void*>(srv));
          srv->_init_state = CHAT_RUN;
          break;
        case CHAT_RUN:
          chat_poll(chat);
          break;
        case CHAT_FINISH:
          chat_free(chat);
          chat = NULL;
          if (srv->_chat_ok) {
            srv->_init_state = PPP_INIT;
          } else {
            srv->_init_state = CHAT_INIT;
          }
          break;
        case PPP_INIT:          
          pppInit();          
          pd = pppOpen(sd, srv->_ppp_status_cb, static_cast<void*>(srv));
          if (pd < 0) {
            syslog (LOG_CRIT, "Cannot open PPP over serial\n");
          }
          pppSetAuth(PPPAUTHTYPE_ANY, PPP_USER, PPP_PASSWORD);          
          srv->_init_state = PPP_INIT_WAIT;
          break;
        case PPP_INIT_WAIT:
          sys_check_timeouts();
          count = sio_read(sd, (u8_t*)rxbuf, buf_length);
          if(count > 0) 
          {
            pppos_input(pd, rxbuf, count);
          }
          else
          {
            sys_msleep(1);
            //cyg_thread_delay(10);
          }
          srv->_init_state = PPP_UP;
          break;        
        case PPP_UP:
          sys_check_timeouts();
          count = sio_read(sd, (u8_t*)rxbuf, buf_length);
          if(count > 0) 
          {
            pppos_input(pd, rxbuf, count);
          }
          else
          {
            sys_msleep(1);
            //cyg_thread_delay(10);
          }
          break;
        case FINISH:
          pppClose(pd);
          /* free chat if reconnect happend whilst chat init */
          if (chat != NULL)
          {
            chat_free(chat);
          }
          srv->_init_state = FINISH_WAIT;
          break;
        case FINISH_WAIT:
          srv->_init_state = CHAT_INIT;
          cyg_thread_delay(20); //wait for x clks
          break;
      }
      cyg_thread_yield();
    }
  }

We do need to port ppp-new branch to ecos as judging from the author's comments
it is more stable than the ppp implementation in vanilla 1.4.1 ppp stack (link:
http://lists.gnu.org/archive/html/lwip-users/2014-03/msg00061.html)

Oleg

-- 
You are receiving this mail because:
You are the assignee for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]