mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-01 19:54:32 +02:00
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:
@@ -1,10 +1,11 @@
|
|||||||
menu "Newlib"
|
menu "Newlib"
|
||||||
|
|
||||||
choice NEWLIB_STDOUT_LINE_ENDING
|
choice NEWLIB_STDOUT_LINE_ENDING
|
||||||
prompt "Line ending for UART output"
|
prompt "Line ending for console output"
|
||||||
default NEWLIB_STDOUT_LINE_ENDING_CRLF
|
default NEWLIB_STDOUT_LINE_ENDING_CRLF
|
||||||
|
depends on VFS_SUPPORT_IO
|
||||||
help
|
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.
|
when a newline ('\n', LF) appears on stdout.
|
||||||
Three options are possible:
|
Three options are possible:
|
||||||
|
|
||||||
@@ -25,10 +26,11 @@ menu "Newlib"
|
|||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
choice NEWLIB_STDIN_LINE_ENDING
|
choice NEWLIB_STDIN_LINE_ENDING
|
||||||
prompt "Line ending for UART input"
|
prompt "Line ending for console input"
|
||||||
default NEWLIB_STDIN_LINE_ENDING_CR
|
default NEWLIB_STDIN_LINE_ENDING_CR
|
||||||
|
depends on VFS_SUPPORT_IO
|
||||||
help
|
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.
|
a newline ('\n', LF) on stdin.
|
||||||
Three options are possible:
|
Three options are possible:
|
||||||
|
|
||||||
|
@@ -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;
|
const char* cdata = (const char*) data;
|
||||||
if (fd == STDOUT_FILENO || fd == STDERR_FILENO) {
|
if (fd == STDOUT_FILENO || fd == STDERR_FILENO) {
|
||||||
for (size_t i = 0; i < size; ++i) {
|
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]);
|
esp_rom_output_tx_one_char(cdata[i]);
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
@@ -53,6 +56,9 @@ ssize_t _read_r_console(struct _reent *r, int fd, void * data, size_t size)
|
|||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (cdata[received] == '\r') {
|
||||||
|
cdata[received] = '\n';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (received == 0) {
|
if (received == 0) {
|
||||||
errno = EWOULDBLOCK;
|
errno = EWOULDBLOCK;
|
||||||
|
@@ -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.serial.bootloader_flash(path_to_mmu_page_size_64k_build)
|
||||||
dut.expect('MMU page size mismatch')
|
dut.expect('MMU page size mismatch')
|
||||||
dut.expect('App is running')
|
dut.expect('App is running')
|
||||||
dut.expect('Partition test done\n')
|
dut.expect('Partition test done')
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.esp32c6
|
@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.serial.bootloader_flash(path_to_mmu_page_size_32k_build)
|
||||||
dut.expect('MMU page size mismatch')
|
dut.expect('MMU page size mismatch')
|
||||||
dut.expect('App is running')
|
dut.expect('App is running')
|
||||||
dut.expect('Partition test done\n')
|
dut.expect('Partition test done')
|
||||||
|
@@ -34,7 +34,7 @@ def test_multicore_app_and_unicore_bootloader(dut: Dut, app_downloader, config)
|
|||||||
if 'psram' in config:
|
if 'psram' in config:
|
||||||
dut.expect(re.compile(r'Adding pool of \d+K of PSRAM memory to heap allocator'))
|
dut.expect(re.compile(r'Adding pool of \d+K of PSRAM memory to heap allocator'))
|
||||||
dut.expect('App is running')
|
dut.expect('App is running')
|
||||||
dut.expect('NVS test done\n')
|
dut.expect('NVS test done')
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.esp32
|
@pytest.mark.esp32
|
||||||
@@ -62,4 +62,4 @@ def test_unicore_app_and_multicore_bootloader(dut: Dut, app_downloader, config)
|
|||||||
if 'psram' in config:
|
if 'psram' in config:
|
||||||
dut.expect(re.compile(r'Adding pool of \d+K of PSRAM memory to heap allocator'))
|
dut.expect(re.compile(r'Adding pool of \d+K of PSRAM memory to heap allocator'))
|
||||||
dut.expect('App is running')
|
dut.expect('App is running')
|
||||||
dut.expect('NVS test done\n')
|
dut.expect('NVS test done')
|
||||||
|
Reference in New Issue
Block a user