Skip to contentSkip to conversation

interrupt programming

DISCUSSION Sayang Oin 2 participants 2 messages Jul 26, 2004 TTY layer and serial drivers

lore
Share & tools
lore

Sayang Oin

author
#0 lore raw

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!

#1 lore raw

On Mon, 2004-07-26 09:24:42 +0200, Sayang Oin <[email protected]> wrote in message <[email protected]>:

Quoted 5 lines

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.

Quoted 1 line

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:)

Quoted 6 lines

here is my routine
....

while(1)

 {
		res=select(fd+1, &rfds, NULL, NULL, &tv);

Hopefully you re-initialize tv before each call to select:)

Quoted 2 lines

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

Signature · 4 lines
Jan-Benedict Glaw       [email protected]    . +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));