LwIP socketstreams

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, utzig, tfAteba, barthess

omcdr
Posts: 89
Joined: Wed Aug 17, 2016 3:25 pm
Has thanked: 7 times
Been thanked: 7 times

LwIP socketstreams

Postby omcdr » Wed Dec 20, 2017 9:33 pm

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);
    }

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: LwIP socketstreams

Postby Giovanni » Wed Dec 20, 2017 9:38 pm

Hi,

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

Giovanni


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 12 guests