[UART] Printing to console while using UART 1

frosticles
Posts: 3
Joined: Fri Jun 30, 2017 4:39 pm

[UART] Printing to console while using UART 1

Postby frosticles » Sun Jul 16, 2017 2:33 pm

Hi,

I'm reading data from UART 1, doing some processing on it, then logging the result to console which is on the default UART 0. The program is extremely unstable when I'm printing to console using either printf() or ESP_LOGI(), but is completely stable when these lines are commented out. The error I get back is "Guru Meditation Error of type LoadProhibited occurred on core 1. Exception was unhandled.", here's what the backtrace usually looks like:

Code: Select all

0x400843de: xQueueTakeMutexRecursive at /Users/frost/esp/esp-idf/components/freertos/./queue.c:2034

0x400826dd: lock_acquire_generic at /Users/frost/esp/esp-idf/components/newlib/./locks.c:155

0x400827c5: _lock_acquire_recursive at /Users/frost/esp/esp-idf/components/newlib/./locks.c:169

0x400eac1a: _vfprintf_r at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/vfprintf.c:860 (discriminator 2)

0x400e4975: printf at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/printf.c:58
And just to make sure I'm not doing something stupid here's the code snippet.

Code: Select all

unsigned char buff[BUF_SIZE];
  while (1) {
    int size = uart_read_bytes(GPS_UART, buff, BUF_SIZE, 1000 / portTICK_RATE_MS);
    if (size > 0) {
    
	...

      for (int i = 0; i < size; i = i + 1) {
        if (buff[i] == (int)'$') {
          if (buff[i + 4] == (int)'G') {
            char GPGGA[120];
            i = i + 7;
            for (int j = 0; j < size; j = j + 1) {
              if (buff[i + j] == (int)'\n') {
                j = size;
              } else {
                GPGGA[j] = (char)buff[i + j];
              }
            }
            printf("here's the GPGGA %s\n", GPGGA);
            // ESP_LOGI("gps", "here's the GPGGA %s\n", GPGGA);
          }
        }
      }
On a side note, is there a way to read complete lines from uart? uart_read_bytes waits until the buffer is full then returns, which almost always cuts off the beginning and ends of the lines. I looked through the source of the uart interrupt routines but I don't really understand them.

Many thanks.

javiec
Posts: 3
Joined: Sat Mar 17, 2018 11:55 pm

Re: [UART] Printing to console while using UART 1

Postby javiec » Sat Mar 17, 2018 11:57 pm

Hello, I have the same problem that you have it. When I try to use the UART_1 and print the result in the UART_0 the systems is really really really unstable, if I comment this lines I dont't have any problem, could you solve this problems?

Thank you.

Who is online

Users browsing this forum: No registered users and 112 guests