* interrupt programming
@ 2004-07-22 10:02 Sayang Oin
2004-07-22 12:20 ` Jan-Benedict Glaw
0 siblings, 1 reply; 4+ messages in thread
From: Sayang Oin @ 2004-07-22 10:02 UTC (permalink / raw)
To: linux-serial
Hello,
I've written a programm to communicate with a external UART device through
/dev/ttyS0.
I use POSIX and Timer but unfortunately is not working well.
Is it possible to use Interrupt to read and write datas through the serial
port?
I'm very thankfull for any hints
best regards
sayangoin
_________________________________________________________________
Wußten Sie, daß Sie Ihren Hotmail-Posteingang auch über den MSN Messenger
abrufen können? http://www.msn.de/messenger Jetzt kostenlos downloaden und
einfach testen!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: interrupt programming
2004-07-22 10:02 interrupt programming Sayang Oin
@ 2004-07-22 12:20 ` Jan-Benedict Glaw
0 siblings, 0 replies; 4+ messages in thread
From: Jan-Benedict Glaw @ 2004-07-22 12:20 UTC (permalink / raw)
To: linux-serial
[-- Attachment #1: Type: text/plain, Size: 1167 bytes --]
On Thu, 2004-07-22 12:02:37 +0200, Sayang Oin <sayangoin@hotmail.com>
wrote in message <BAY15-F22wSs3yoW3Al0005522c@hotmail.com>:
> I've written a programm to communicate with a external UART device through
> /dev/ttyS0.
> I use POSIX and Timer but unfortunately is not working well.
What do you need timers for? If you're waiting for data, just use
select(). That even allows you to perform other actions every now and
then.
> Is it possible to use Interrupt to read and write datas through the serial
> port?
Linux' serial driver should work interrupt-driven most of the time. Only
in rare cases it'll poll the serial chip, but I think that's not really
your problem.
Please tell us what you *really* need to do. Then, we'd help you.
Sources of your application to comment on weren't wrong, too...
MfG, JBG
--
Jan-Benedict Glaw jbglaw@lug-owl.de . +49-172-7608481 _ O _
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg _ _ O
fuer einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: interrupt programming
@ 2004-07-26 7:24 Sayang Oin
2004-07-26 8:08 ` Jan-Benedict Glaw
0 siblings, 1 reply; 4+ messages in thread
From: Sayang Oin @ 2004-07-26 7:24 UTC (permalink / raw)
To: linux-serial
Hallo,
I have to use timer because I have to communicate with other programm via
filestream
and I use this timer also for scheduling the time that I have to send data
to my device.
people said if I use interrupt so I can be sure I will not lose my datas.
here is my routine
....
while(1)
{
res=select(fd+1, &rfds, NULL, NULL, &tv);
if(res==0)
{
tries++;
if(tries==8)
return 0;
}
n = read (fd, p, 1);
if(n>0)
{
printf(" %X \n", buffer[rd]);
p++;
rd++;
}
// up here I analyze my datas.
// if everythings ok I jump out of the while
return rd;
}
....
best regards
sayangoin
_________________________________________________________________
Wußten Sie, daß Sie Ihren Hotmail-Posteingang auch über den MSN Messenger
abrufen können? http://www.msn.de/messenger Jetzt kostenlos downloaden und
einfach testen!
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: interrupt programming
2004-07-26 7:24 Sayang Oin
@ 2004-07-26 8:08 ` Jan-Benedict Glaw
0 siblings, 0 replies; 4+ messages in thread
From: Jan-Benedict Glaw @ 2004-07-26 8:08 UTC (permalink / raw)
To: linux-serial
[-- Attachment #1: Type: text/plain, Size: 1838 bytes --]
On Mon, 2004-07-26 09:24:42 +0200, Sayang Oin <sayangoin@hotmail.com>
wrote in message <BAY15-F21ZXn97cvZvK00022be7@hotmail.com>:
>
> I have to use timer because I have to communicate with other programm via
> filestream
> and I use this timer also for scheduling the time that I have to send data
> to my device.
That's quite DOSsish thinking. You've got several variants you can
choose from:
1. Use non-blocking I/O with select() and toggle between your
two (or several) tasks.
2. Separate all workplaces into one thread each.
2b. Mix both variants.
> people said if I use interrupt so I can be sure I will not lose my datas.
You can't be *sure* to not loose data. Even with using interrupts, there
are possible conditions in which you'd loose some bytes of data due to
overflows. Think eg. about long-running IDE interrupts. While they're
running, no other IRQs will be serviced (unless you've got several
CPUs--it may be different in that case). That is, if eg. a 16byte FIFO
of a serial UART fills up, it'll overrun. At 115200 Baud, you need
little less than 1.5ms -- IDE interrupts can go up over 500ms easily, at
least with no DMA:)
> here is my routine
> ....
>
> while(1)
> {
> res=select(fd+1, &rfds, NULL, NULL, &tv);
Hopefully you re-initialize tv before each call to select:)
> return rd;
> }
But that's all not your problem. Your UART (or it's driver) thinks it's
not allowed to send out data. There's the problem.
MfG, JBG
--
Jan-Benedict Glaw jbglaw@lug-owl.de . +49-172-7608481 _ O _
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg _ _ O
fuer einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-07-26 8:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-22 10:02 interrupt programming Sayang Oin
2004-07-22 12:20 ` Jan-Benedict Glaw
-- strict thread matches above, loose matches on Subject: below --
2004-07-26 7:24 Sayang Oin
2004-07-26 8:08 ` Jan-Benedict Glaw
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox