LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-03-2017, 04:52 AM   #1
tleroyy
LQ Newbie
 
Registered: Jul 2017
Posts: 1

Rep: Reputation: Disabled
High Resolution Timer problem


Hello there,

I am curently working on a Linux-based operating system called Nuttx on pixhawk architecture : pixhawk.org .

I am implementing a periodic called function with HRT library. Here is my code :

Code:
int debug_thread_main(int argc, char *argv[]);
hrt_callout tocall(void);

int debug_main(int argc, char *argv[])
{
  //Task create , max priority, stack size=2000
  px4_task_spawn_cmd("debug",
                     SCHED_DEFAULT,
                     SCHED_PRIORITY_MAX,
                     2000,
                     debug_thread_main,
                     (char * const *)&argv[0]);
  return OK;
}

int debug_thread_main(int argc, char *argv[])
{
 struct hrt_call entry;
 //hrt_abstime in ms
 hrt_abstime delay=1000, interval=1000;

 hrt_init();
 hrt_call_init(&entry);

 hrt_call_every( &entry, delay, interval,tocall(),NULL);

 return 0;
}



hrt_callout tocall(void) {                // Where: typedef void (* hrt_callout)(void *arg);
 hrt_abstime time = hrt_absolute_time();
 PX4_INFO("I am call at : %d", time); 
 return tocall(); 
}
My problem is that the timer always stay at the same value 'time=240' or in hexa 0xf0:
https://img4.hostingpics.net/pics/920594hrtproblem.png

So the call_every function is not working well, interval delay is not working and the function is call as if it was in a while(1) loop.

Thanks for helping me

Last edited by tleroyy; 07-03-2017 at 05:00 AM.
 
Old 07-22-2017, 03:48 AM   #2
Jjanel
Member
 
Registered: Jun 2016
Distribution: any&all, in VBox; Ol'UnixCLI; NO GUI resources
Posts: 999
Blog Entries: 12

Rep: Reputation: 363Reputation: 363Reputation: 363Reputation: 363
Hello, and welcome to LQ! Sorry your post didn't get a reply on LQ,
but it is very specialized (vs. general Linux). Looks like you solved it:
http://discuss.px4.io/t/hrt-absolute...-return-0/3749
>"somehow I made it works using directly the clock_gettime() function."

Anyways, I hope you don't give up on LQ: it's a GREAT forum

And 'best wishes' on what sounds like a great project!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to write a high resolution timer krishnammanaidu Linux - Newbie 3 06-18-2014 08:32 AM
High Resolution Timer Support???? Southpaw76 Linux - Kernel 2 11-20-2009 02:46 AM
Check for high resolution timer nonis Linux - Software 3 05-04-2009 07:24 AM
High Resolution Timer over 1000hz antidelldude Linux - General 0 01-29-2008 07:10 AM
[n] Slackware High Resolution Problem nirav_patel Slackware 9 05-13-2005 04:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration