- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm trying to write an application that polls at regular intervals my hardware via serial port. What I need is an event that calls a function at regular times without charge the CPU usage. What can I do? I tried different solutions without succes. I read something about kernel timers, but I don't need to wirte a driver for the kernel. Can somebody give me an input? thanks stepaLink Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi stepa,
> What I need is an event that calls a function at regular times I'm assuming you want to access the hardware directly? ... Without using the serial driver? If so, you can use the select() system call to wakeup periodically. E.g.:<div class='quotetop'>QUOTE </div> --- Quote Start --- while (1) { /* Wait for 100 ms */ tv.tv_sec = 0; tv.tv_usec = 100 * 1000; result = select (0, NULL, NULL, NULL, &tv); /* Sleep */ /* Do the periodic check */ }[/b] --- Quote End --- See the manpage for details on select() -- it's a pretty complete manpage :-) Regards, --Scott- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Scott,
sorry for the delay of my answer, but I spent some days at home. Thank you for your answer. <div class='quotetop'>QUOTE </div> --- Quote Start --- I'm assuming you want to access the hardware directly? ... Without using the serial driver? [/b] --- Quote End --- I've a device connected to the Nios via rs232. My application has to poll the device periodically to read his status and if somthing changes it sends SNMP traps. I tried the select example code this morning and it seems to work. I'm pretty new in uClinux and so I have some questions: - is my solution good or is it better to write a kernel driver, and to use kernel timers or task queues or something else? thanks, StePa- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I was looking for some help on using the select() system call and I've found this topic. My problem is about a multi-threaded application getting stuck (all pthreads generated by this application) when it enters a select which should sleep on a tty. Both the tty driver and the peripheral are custom made. Both worked on an older kernel version: the problem raised this year when we tried to port the system to v 2.6.28 and still persists on v 2.6.30 The thing which upsets me is that the application could hang for an indefinite time until I make some collateral traffic, e.g. : opening another shell via telnet and launching a top, pressing some buttons (another custom couple of IP and driver). In case someone would like to help me, what do you need? Which info? (code snippets, sources, info about kernel compilation options... just tell me) Thanks in advance, gabrigob- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, fyi (if someone found interesting this topic)
we made some other tests and the driver and the uart seem to work correctly together. We have some troubles with the scheduling in the application. We had to lower the system timer frequency... Does any experienced programmer knows if the scheduler has grown in complexity enough?
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page