Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By itmarshall
#47438 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
User avatar
By smh
#48146 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
User avatar
By rvireday
#52676 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.