-->
Page 2 of 3

Re: Compiling in support for the UART

PostPosted: Sat May 14, 2016 8:15 am
by itmarshall
G'day smh,

Well, I don't think my forehead will ever be quite the same shape again after hitting it on so many brick walls, but I've finally got something working!

The things I had to do were:
1. Copy the "examples/driver_lib/driver/uart.c" and "examples/driver_lib/include/driver/uart*.h" files from the SDK to the local project (under the "driver" and "include/driver" directories respectively.)
2. Alter the "include/espmissingincludes.h" file to include the "os_type.h" file.
3. Make the following changes to the "uart.c" file:
    * Add include for "espmissingincludes.h"
    * Add include for "user_interface.h"
    * Create a forward definition to a function called "uart_rx_task"
    * Remove the "uart_recv_task" function
    * Alter the "system_os_task" call to create the "uart_recvTaskPrio" task to point to the "uart_rx_task"
4. Add the "uart_rx_task" function to my "user_main.c" file. Here is where we process messages received from the UART
5. Alter the makefile to look for the "uart.c" file under the "driver" directory

After all that, I could use the "uart_init" and "uart0_tx_buffer" functions and receive updates in my "uart_rx_task" function.

I wrote a post (yes, another techie playing with a blog - sorry!) about this solution: http://smallbits.marshall-tribe.net/blog/2016/05/14/esp8266-uart-fun and have put some sample code up on GitHub: https://github.com/itmarshall/esp8266-projects/tree/master/uart-blink. If there's anything unclear there, or could be better explained, please let me know as it is probably painfully obvious that I'm an engineer, not a writer and can't do words too good. ;)

Cheers,

Ian

Re: Compiling in support for the UART

PostPosted: Mon May 16, 2016 7:22 am
by smh
Awesome! I'll give this a try and let you know how it goes.

Re: Compiling in support for the UART

PostPosted: Sat May 28, 2016 12:43 am
by smh
Hi Ian,

I finally got around to running your code, worked great and I've modified it for my own project where GPS nmea data is now coming into the esp8266 via the UART.

Nice blog post about it too, might be worth adding a line to mention input for the different time delays is via the keyboard and in milliseconds (correct?).

Side note: I used screen to enter the input and view the output and that worked fine.

-smh

Re: Compiling in support for the UART

PostPosted: Wed Aug 10, 2016 6:56 pm
by rvireday
Ditto.

Without setting up a callback, is there a simple version in C that does the same thing as fgets()? Read a string until a newline?

I just want to communicate on the serial line, before bouncing up to others.