From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Yigal Goldberger <yigal_gold@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] serial com errors
Date: Sun, 13 Dec 2009 16:05:00 +0100 [thread overview]
Message-ID: <4B25029C.9020703@domain.hid> (raw)
In-Reply-To: <801038.31731.qm@domain.hid>
Yigal Goldberger wrote:
> Hi Again,
>
> I hope it's not too long and tiring ...
> But the relevant code (I think...) is the initialization stage , and the select and read loop that blocks and reads .
>
>
> The problem is as follows :
> I have 2 threads listening on two different serial coms . running the same code below . Using select to block and wait for bytes to be available on the port , and then reading them with the read function .
> These 2 threads are Xenomai threads with priority higher then the thread that is responsible of working on the data .
> I see that when reaceiving with BAUDRATES lower than 115200 (38400) no problem occures , and when receving on both port with BAUDRATE 115200 , I get errors in the received bytes ( which is identified by a wrong checksum ,and sometimes with a "No more room in flip buffer" printout on the console as well as errno 11 (EAGAIN) ) . When I added a 10 mili second sleep to the executing thread (the thread that uses the data )the problem seems to disappear .
>
>
> Below is the 2 code parts that Initialize the file descriptor of the reading thread , and the reading select - read loop :
>
> while (TRUE)
> {
> if (thistlp->nbytes_to_read == 1)
> {
> int xxx = tcgetattr (thistlp->fd, &thistlp->ttykey);
> }
>
> if ((nbytes = select (thistlp->fd+1, &input, NULL, NULL,pIo_timeout /*NULL*/)) < 0)
Please read select documentation, this use of select is wrong in at
least two ways:
- select return value is not a number of bytes, it is a number of file
descriptors;
- the input fdset is modified by select to indicate which file
descriptors are ready, so you must reset it to the proper value before
each call to select.
--
Gilles.
next prev parent reply other threads:[~2009-12-13 15:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-07 9:57 [Xenomai-help] serial com errors Yigal Goldberger
2009-12-13 15:05 ` Gilles Chanteperdrix [this message]
2009-12-13 15:12 ` Gilles Chanteperdrix
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B25029C.9020703@domain.hid \
--to=gilles.chanteperdrix@xenomai.org \
--cc=xenomai@xenomai.org \
--cc=yigal_gold@domain.hid \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.