Page 1 of 1

LwIP socketstreams

Posted: Wed Dec 20, 2017 9:33 pm
by omcdr
I'm using this code https://github.com/wizhippo/stm32f4-chibios-lwip-pppos/blob/master/lib/lwip/socketstreams.c to use LwIP socket as stream.
I can write with chnWrite, but I have problems with read, I got random chars.

With chnReadTimeout I got compile error: 'const struct BaseSequentialStreamVMT' has no member named 'readt'
Is is possible to use timeout version with wrapper like this ? How to add timeout check ?
Is there another working example ?


Code: Select all

THD_FUNCTION(console_thd, arg)
{
   console_t *con;
   msg_t msg;
   char input;


    con = arg;
    BaseSequentialStream* chp = con->bss;
   int i=0;
    uint8_t c;
    while (1)
    {

       chnWrite(chp, (uint8_t *)'A', 1);     
//       if(c !=0)
//         chnWrite(chp, (uint8_t *)(c+1), 1);

       if (chnRead(chp, &c, 1) == 0)
            c = 0;
//       if (chnReadTimeout(chp, &c, 1, MS2ST(100)) == 0)
//            c = 0;

        chThdSleepMilliseconds(500);
    }

Re: LwIP socketstreams

Posted: Wed Dec 20, 2017 9:38 pm
by Giovanni
Hi,

Streams do not support timeouts, timeouts are introduced by a derived interface called channels (see the chn prefix in the macro).

Giovanni