Is it possible to call clock_nanosleep() from PB and, if possible, can someone more adept at C than me provide an example.
http://www.kernel.org/doc/man-pages/onl ... eep.2.html
nanosecond timer
first step.
don't work , but this is the good way.
don't work , but this is the good way.
Code: Select all
#CLOCK_REALTIME = 0
#CLOCK_MONOTONIC = 1
#CLOCK_PROCESS_CPUTIME_ID = 2
#CLOCK_THREAD_CPUTIME_ID = 3
#CLOCK_REALTIME_HR = 4
#CLOCK_MONOTONIC_HR = 5
Structure timespec
tv_sec.i; /* seconds */
tv_nsec.i; /* nanoseconds [0 .. 999999999] */
EndStructure
ImportC "-lrt"
clock_nanosleep(clockid.i,b.i,c.i,d.i)
EndImport
clock_nanosleep(#CLOCK_MONOTONIC,0,0,0)
Re: nanosecond timer
at least to have a working example
:

Code: Select all
;Clock-ID's = Type of clock to use
#CLOCK_REALTIME = 0
#CLOCK_MONOTONIC = 1
#CLOCK_PROCESS_CPUTIME_ID = 2
#CLOCK_THREAD_CPUTIME_ID = 3
#CLOCK_REALTIME_HR = 4
#CLOCK_MONOTONIC_HR = 5
;Flags
#TIMER_ABSTIME=1; if used, the remain variable could be set to #NULL
Structure timespec
tv_sec.i; /* seconds */
tv_nsec.i; /* nanoseconds [0 .. 999999999] */
EndStructure
; see http://www.kernel.org/doc/man-pages/online/pages/man2/clock_nanosleep.2.html
ImportC "-lrt"
clock_nanosleep(clockid.i,flags.i,requested.i,remain.i)
EndImport
time.timespec ; requested nanosleep
rem.timespec; remaining time if interrupted
time\tv_sec=10
time\tv_nsec=666
error=clock_nanosleep(#CLOCK_MONOTONIC,0,@time,@rem)
If error<>0
;interupted by signal or error occured
Debug error
EndIf
Last edited by walker on Sun Sep 13, 2009 4:41 pm, edited 1 time in total.
Re: nanosecond timer
Thank you.walker wrote:at least to have a working example:
