This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
RE: Getting number of chars available (FIONREAD)
- From: "Rick Davis" <rickdavisjr at comcast dot net>
- To: "'Henning Baldersheim'" <henning dot baldersheim at devoll dot no>,<ecos-discuss at sources dot redhat dot com>
- Date: Sat, 20 Mar 2004 06:29:22 -0500
- Subject: [ECOS] RE: Getting number of chars available (FIONREAD)
Henning,
Use the following. It is a snippet from some console code I use.
#include <cyg/io/flash.h>
#include <cyg/hal/hal_arch.h>
#include <cyg/kernel/kapi.h>
#include <cyg/hal/hal_diag.h>
#include <cyg/hal/hal_if.h>
#include <cyg/io/io.h>
#include <cyg/io/serialio.h>
#define CONSOLE_DEVICE "/dev/ser0"
cyg_io_handle_t console_handle;
char cc;
int num_read;
cyg_serial_buf_info_t buff_info;
int len;
num_read;
if (cyg_io_lookup (CONSOLE_DEVICE, &console_handle) >= 0)
{
len = sizeof (buff_info);
cyg_io_get_config (console_handle, CYG_IO_GET_CONFIG_SERIAL_BUFFER_INFO,
&buff_info, &len);
if (buff_info.rx_count)
{
num_read = 1;
cyg_io_read (console_handle, &cc, &num_read);
}
}
I hope this helps,
Rick
-----Original Message-----
From: Henning Baldersheim [mailto:henning.baldersheim@devoll.no]
Sent: Friday, March 19, 2004 1:32 AM
To: ecos-discuss@sources.redhat.com
Subject: Getting number of chars available (FIONREAD)
Hi
I am trying to get the number of bytes already available at my serial port.
Normally I would have used ioctl with FIONREAD, but neither ioctl nor
FIONREAD seem to exist.
How do I do that than ?
Henning
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss