lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-devel] lwIP + SLIP/PPP single threaded


From: Alain M.
Subject: Re: [lwip-devel] lwIP + SLIP/PPP single threaded
Date: Mon, 08 Dec 2008 19:03:23 -0200
User-agent: Thunderbird 2.0.0.17 (X11/20080914)


Simon Kallweit escreveu:
sio_send and sio_recv are obviously blocking. Is sio_read and sio_write designed to be purly non-blocking?
They are not really blocking...

sio_send will return after all char are sent. As far as I know, outgoing cannot be blocked by HW hand-shake.

sio_read has a companion sio_read_abort that is suposed to unblock it. This is not implemented in Linux, but I made a simple implementation (see bellow)

I cannot help you with more than that because my PPP is not working too. I sent a message an the users list but got no answer.

I have been studying lwip's PPP and I also found that it is a bit complicated, probably a single threared one would be nice. BUT, I gess that to make it's way to the official distro it has to be as complete as the current one.

Alain
CODE:

volatile static int sio_abort_flag = 0;
u32_t sio_read(sio_status_t * siostat, u8_t *buf, u32_t size)
{
   fd_set readfs;    /* file descriptor set */
   int res;
   struct timeval Timeout;
   sio_abort_flag = 0;
   FD_ZERO(&readfs);
   FD_SET(siostat->fd, &readfs);  /* set testing for source fd */
   while (!sio_abort_flag){
       /* set timeout value within input loop */
       Timeout.tv_usec = 0;  /* milliseconds */
       Timeout.tv_sec  = 1;  /* seconds */
       res = select(siostat->fd+1, &readfs, NULL, NULL, &Timeout);
       if (res>0)
           return read( siostat->fd, buf, size );
   }
   printf("sio_read: aborted......\n");
   return 0;
}

void sio_read_abort(sio_status_t * siostat)
{
sio_abort_flag = 1;
printf("sio_read_abort: aborting\n");
}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]