Skip to content

Commit 1a302cb

Browse files
committed
Merge branch 'bugfix/open_uart_non_blocking' into 'master'
Make UART non-blocking when the file descriptor was opened with the O_NONBLOCK flag See merge request idf/esp-idf!2153
2 parents 53234ef + c55987a commit 1a302cb

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

components/vfs/vfs_uart.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,22 @@ static int uart_open(const char * path, int flags, int mode)
9191
{
9292
// this is fairly primitive, we should check if file is opened read only,
9393
// and error out if write is requested
94+
int fd = -1;
95+
9496
if (strcmp(path, "/0") == 0) {
95-
return 0;
97+
fd = 0;
9698
} else if (strcmp(path, "/1") == 0) {
97-
return 1;
99+
fd = 1;
98100
} else if (strcmp(path, "/2") == 0) {
99-
return 2;
101+
fd = 2;
102+
} else {
103+
errno = ENOENT;
104+
return fd;
100105
}
101-
errno = ENOENT;
102-
return -1;
106+
107+
s_non_blocking[fd] = ((flags & O_NONBLOCK) == O_NONBLOCK);
108+
109+
return fd;
103110
}
104111

105112
static void uart_tx_char(int fd, int c)

0 commit comments

Comments
 (0)