posix function (read/write) unusual beavior
Gabriel Ibarra
gabriel.ibarra at tallertechnologies.com
Mon Jul 21 14:42:51 UTC 2014
Hi, I have a simple loopback program in my board (bsp lpc_176x), It reads
information from a tty and returns it through the same tty (using POSIX
functions), I tested it sending characters with a PC's terminal and I saw
the ECHO on the terminal, I found an unusual behavior with some bsp
configurations, sometimes the first character that I send is returned dirty
(some extra bytes are sent), after this first dirty character the program
works well.
Example:
-------------------------------------------------------------------------------------------
void configureUart(const int fd)
{
struct termios options;
tcgetattr(fd, &options);
//Set raw mode
cfmakeraw(&options);
tcsetattr(fd, TCSANOW, &options);
}
rtems_task Init(
rtems_task_argument ignored
)
{
const int fd = open(TTYSO, O_RDWR);
if (fd >= 0)
{
configureUart(fd);
char buffer[1u];
while (true)
{
if (read(fd, buffer, 1u) == 1u)
{
write(fd, buffer, 1u);
}
}
close(fd);
}
while(1);
}
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_MAXIMUM_TASKS 1
#define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 2
#define CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
#define CONFIGURE_MAXIMUM_DEVICES 5
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_INIT
#define CONFIGURE_STACK_CHECKER_ENABLED
#include <rtems/confdefs.h>
-------------------------------------------------------------------------------------------
In this example, when i press 0123456789 the output looks like:
]�\ B�\^0123456789
I said "with some configurations" because I found that if I define maximum
devices to 4 (#define CONFIGURE_MAXIMUM_DEVICES 4) it works well, but
with #define
CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4 and if I remove #define
CONFIGURE_STACK_CHECKER_ENABLED the problem appears again.
I don't know if I'm doing something bad or if it is a bug, Can someone help
me with that?
Thanks,
--
Gabriel Alejandro Ibarra
Software Engineer
San Lorenzo 47, 3rd Floor, Office 5
Córdoba, Argentina
Phone: +54 351 4217888
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20140721/21906813/attachment-0001.html>
More information about the devel
mailing list