espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.33k stars 7.2k forks source link

uart send the variable in the same package (IDFGH-12384) #13412

Open MatheusCaltran opened 5 months ago

MatheusCaltran commented 5 months ago

Answers checklist.

IDF version.

v5.2.0

Espressif SoC revision.

ESP32-D0WD-V3 (revision 3)

Operating System used.

Windows

How did you build your project?

VS Code IDE

If you are using Windows, please specify command line type.

None

Development Kit.

ESP32 Dev Kit V1

Power Supply used.

USB

What is the expected behavior?

I would like to send a variable via serial at the highest possible speed and in different packages.

What is the actual behavior?

When I send it via serial every 1 second the variable goes in a different package (I'm using a converter to read it with my device using the Geshe DB Genius)

Using Geshe DB Genius read 1000ms: image

If I send it every 5 ms, the variable goes in the same package: Using Geshe DB Genius read 5ms: image

I tried using "uart wait_tx_done" but it still worked the same.

Steps to reproduce.

/* UART Echo Example

This example code is in the Public Domain (or CC0 licensed, at your option.)

Unless required by applicable law or agreed to in writing, this software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */

include

include "freertos/FreeRTOS.h"

include "freertos/task.h"

include "driver/uart.h"

include "driver/gpio.h"

include "sdkconfig.h"

include "esp_log.h"

include "string.h"

static void echo_task(void *arg) { const uart_port_t uart_num = UART_NUM_2; uart_config_t uart_config = { .baud_rate = 115200, .data_bits = UART_DATA_8_BITS, .parity = UART_PARITY_DISABLE, .stop_bits = UART_STOP_BITS_1, .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, .rx_flow_ctrl_thresh = UART_SCLK_APB, }; // Configure UART parameters ESP_ERROR_CHECK(uart_param_config(uart_num, &uart_config));

ESP_ERROR_CHECK(uart_set_pin(UART_NUM_2, 17, 16, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));

const int uart_buffer_size = (1024 * 2);
QueueHandle_t uart_queue;
// Install UART driver using an event queue here
ESP_ERROR_CHECK(uart_driver_install(UART_NUM_2, uart_buffer_size, \
                                    uart_buffer_size, 10, &uart_queue, 0));

 // Write data to UART.
char* test_str = "This is a test string.\n\r";

while (1) {

    uart_write_bytes(uart_num, (const char*)test_str, strlen(test_str));
    vTaskDelay(pdMS_TO_TICKS(5));

}

}

void app_main(void) { xTaskCreate(echo_task, "uart_echo_task", CONFIG_EXAMPLE_TASK_STACK_SIZE, NULL, 10, NULL); }

Debug Logs.

No response

More Information.

No response

nopnop2002 commented 5 months ago

There may be a problem with inter-character timeout in the receiving application (Geshe DB Genius).

Please review the inter-character timeout.

You need to keep inter-character timeout to less than 5ms.

If the timeout is greater than this, characters received 5 milliseconds apart will be the same packet.

However, some applications do not allow you to specify a inter-character timeout.