Re: A little doubt of methodology
Peter Soetens <[email protected]> Tue, 22 May 2007 09:30:22 +0200
| Newsgroups | gmane.science.robotics.orocos.user |
|---|---|
| Message-ID | <[email protected]> |
Quoting Leopold Palomo-Avellaneda <[email protected]>: > A Dilluns 21 Maig 2007 14:26, Peter Soetens va escriure: >> On Monday 21 May 2007 11:32:37 Leopold Palomo-Avellaneda wrote: >> > Dear people, >> > >> > I have a little doubt. I'm developing a program that use the network. So, >> > the idea is to have a task that listen the socket. When I create the >> > task, this task is a periodic task, and an x miliseconds a run the task, >> > or a nonpeeriodic task, and when the socket receive some data, then this >> > emits something through the data port? >> >> Even if your data packets come in periodically, it won't work well using a >> periodic task, as the sender will not have the exact period as the >> receiving task (due to clock drift). Hence, your receiver is better non >> periodic and blocks on the socket for new data. > > Normal .... > >> In RTT 1.2.0, there is better support for these cases. The discussion was >> held here: <https://www.fmtc.be/orocos-bugzilla/show_bug.cgi?id=353>, >> you'll need to use the discussed trigger() function as well. > > Ok, > > so reading the thread I understand that I have to create a nonPeriodicTask > (yes, bad name, but ...) and then the in the update function put the recv > command of the networks, no? Exactly. > > > void update() > { > // ... here comes my algorithm... > //.... > > // ex. ret = rt_dev_recv(sockfd, msg, sizeof(msg), 0); > > // if some condition is met: > this->getActivity()->trigger(); > } If you write your code like this, start() your component and then wish to stop() it again, stop() will wait until update() returns, thus make sure that rt_dev_recv has a time-out or so, otherwise, stop() will appear to freeze (until a network packet arrives) Peter -- www.fmtc.be ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. -- Orocos mailing list [email protected] http://lists.mech.kuleuven.be/mailman/listinfo/orocos