ESP8266 UART

SerialIn the MQTT implementation, the UART is used for status only – in other words the input is not used.

I’m a little vague on how to use the serial input. I am assuming there is an empty function in which you have to implement your own queue   – but it’s not at all clear. Can anyone who has looked into this give a simple (C language, not LUA) example of the use of the serial input (ignoring speed setup as that’s done for the serial monitoring already).

Advertisements

10 thoughts on “ESP8266 UART

  1. His example is great – but also confusing..

    int c = uart0_rx_one_char();

    if(c != -1) {
    char out[30];
    os_sprintf(out,”received %c”,c);
    debug(out);
    }

    Looks like he’s expecting to read up to 30 chars – but then says he’s only taking one !!?!!?!?

  2. I’ve just realised that excellent though this is – there’s a snag. If you take the MQTT software for example, it is all even driven – so unlike Arduino there is no LOOP where you can sit polling software. What might be more useful might be a callback function, say when ENTER is entered into the serial, the callback function would let you both preview and retrieve characters from the queue so as a pretty crude example and probably not a good one…

    serialCB()
    {
    char buffer[50],;
    char *bp;
    bp=buffer;
    while (1)
    {
    a=serialinCheck(); if ((a==13) ||(a==-1)) break;
    *bp++=serialin();
    }
    *bp=0;
    // do something with buffer
    }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s