Merge branch 'feat/uart_line_ending' into 'master'

feat(console): change line endings on standard input and output

Closes IDF-11467

See merge request espressif/esp-idf!34459
This commit is contained in:
Roland Dobai
2024-11-20 15:36:01 +08:00
4 changed files with 16 additions and 8 deletions

View File

@@ -1,10 +1,11 @@
menu "Newlib"
choice NEWLIB_STDOUT_LINE_ENDING
prompt "Line ending for UART output"
prompt "Line ending for console output"
default NEWLIB_STDOUT_LINE_ENDING_CRLF
depends on VFS_SUPPORT_IO
help
This option allows configuring the desired line endings sent to UART
This option allows configuring the desired line endings sent to console
when a newline ('\n', LF) appears on stdout.
Three options are possible:
@@ -25,10 +26,11 @@ menu "Newlib"
endchoice
choice NEWLIB_STDIN_LINE_ENDING
prompt "Line ending for UART input"
prompt "Line ending for console input"
default NEWLIB_STDIN_LINE_ENDING_CR
depends on VFS_SUPPORT_IO
help
This option allows configuring which input sequence on UART produces
This option allows configuring which input sequence on console produces
a newline ('\n', LF) on stdin.
Three options are possible:

View File

@@ -33,6 +33,9 @@ ssize_t _write_r_console(struct _reent *r, int fd, const void * data, size_t siz
const char* cdata = (const char*) data;
if (fd == STDOUT_FILENO || fd == STDERR_FILENO) {
for (size_t i = 0; i < size; ++i) {
if (cdata[i] == '\n') {
esp_rom_output_tx_one_char('\r');
}
esp_rom_output_tx_one_char(cdata[i]);
}
return size;
@@ -53,6 +56,9 @@ ssize_t _read_r_console(struct _reent *r, int fd, void * data, size_t size)
if (status != 0) {
break;
}
if (cdata[received] == '\r') {
cdata[received] = '\n';
}
}
if (received == 0) {
errno = EWOULDBLOCK;

View File

@@ -27,7 +27,7 @@ def test_app_mmu_page_size_32k_and_bootloader_mmu_page_size_64k(dut: Dut, app_do
dut.serial.bootloader_flash(path_to_mmu_page_size_64k_build)
dut.expect('MMU page size mismatch')
dut.expect('App is running')
dut.expect('Partition test done\n')
dut.expect('Partition test done')
@pytest.mark.esp32c6
@@ -49,4 +49,4 @@ def test_app_mmu_page_size_64k_and_bootloader_mmu_page_size_32k(dut: Dut, app_do
dut.serial.bootloader_flash(path_to_mmu_page_size_32k_build)
dut.expect('MMU page size mismatch')
dut.expect('App is running')
dut.expect('Partition test done\n')
dut.expect('Partition test done')

View File

@@ -34,7 +34,7 @@ def test_multicore_app_and_unicore_bootloader(dut: Dut, app_downloader, config)
if 'psram' in config:
dut.expect(re.compile(r'Adding pool of \d+K of PSRAM memory to heap allocator'))
dut.expect('App is running')
dut.expect('NVS test done\n')
dut.expect('NVS test done')
@pytest.mark.esp32
@@ -62,4 +62,4 @@ def test_unicore_app_and_multicore_bootloader(dut: Dut, app_downloader, config)
if 'psram' in config:
dut.expect(re.compile(r'Adding pool of \d+K of PSRAM memory to heap allocator'))
dut.expect('App is running')
dut.expect('NVS test done\n')
dut.expect('NVS test done')