[RTEMS Project] #4926: open() non-blocking mode. not posix compliant
RTEMS trac
trac at rtems.org
Wed Jul 12 07:30:21 UTC 2023
#4926: open() non-blocking mode. not posix compliant
----------------------+--------------------
Reporter: yangn0 | Owner: (none)
Type: defect | Status: new
Priority: high | Milestone:
Component: posix | Version: 6
Severity: blocker | Keywords:
Blocked By: | Blocking:
----------------------+--------------------
{{{
#include <rtems.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <rtems/error.h>
#include <string.h>
void writeUart(int fd, int i)
{
char str[80];
sprintf(str, "Hello /dev/ttyAMA%d\n", i);
int ret = write(fd, str, strlen(str));
if (ret <= 0)
{
printf("send str error. error no: %d\n", errno);
}
}
rtems_task Init(
rtems_task_argument ignored)
{
int ttyS[5] = {-1};
char s[80];
int i;
printf("hello uart\n");
int fd = open("/dev/ttyAMA2", O_RDWR | O_NOCTTY | O_NONBLOCK);
if (fd == -1)
{
puts("fd==-1 !!");
exit(0);
}
printf("fd=%d\n", fd);
static uint16_t btstack_uart_block_read_bytes_len=1;
char buffer[20]={'\0'};
ssize_t bytes_read = read(fd, buffer,
btstack_uart_block_read_bytes_len);
printf("bytes_read=%d\n",bytes_read);
printf("buffer=%s\n",buffer);
printf("end uart\n");
exit(0);
}
}}}
when open() set O_NONBLOCK. read() still blocks.
output:
{{{
hello uart
fd=3
}}}
**Expected behavior**
in other POSIX system(Ubuntu):
{{{
hello uart
fd=3
bytes_read=-1
buffer=-1
end uart
}}}
--
Ticket URL: <http://devel.rtems.org/ticket/4926>
RTEMS Project <http://www.rtems.org/>
RTEMS Project
More information about the bugs
mailing list