Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loop a command in VxWorks at a certain frequency

I am attempting to loop a command in VxWorks around 6Hz, I cannot compile code for the target in question so I have to use existing VxWorks shell commands

I have tried:

repeat(1000,functionX,param1,param2,param3)

This works well at repeating the command 1000 times but wont give me the frequency I require

As a comprimise I looked at:

period() 

as this is capable of giving me 1hz calls on the function (which might be acceptable) however I cannot work out how to enter the required parameters into the FunctionX I have tried both:

period(1,functionX,param1,param2,param3)

and

period(1,functionX(param1,param2,param3))

with no luck

Any Ideas on how to acheive the 6Hz rate for FunctionX would be great but if that is not possible without compiling some code then I will settle for a way of getting the period command to work with parameters in the function I am calling

like image 973
GeorgeM Avatar asked Nov 20 '25 13:11

GeorgeM


1 Answers

Repeat and period have the same signatures, but the interpretation of the first parameter is different. So if you can call repeat successfully then you can also call period successfully.

int period
    (
    int     secs,             /* period in seconds */
    FUNCPTR func,             /* function to call repeatedly */
    int     arg1,             /* first of eight args to pass to func */
    int     arg2,
    int     arg3,
    int     arg4,
    int     arg5,
    int     arg6,
    int     arg7,
    int     arg8
    )



int repeat
    (
    int     n,                /* no. of times to call func (0=forever) */
    FUNCPTR func,             /* function to call repeatedly */
    int     arg1,             /* first of eight args to pass to func */
    int     arg2,
    int     arg3,
    int     arg4,
    int     arg5,
    int     arg6,
    int     arg7,
    int     arg8
    )

For repeat the first parameter, is the number of times to call the function, and for period the first parameter is the period in seconds

So period is really too slow for you, and repeat is too fast, though you could use tickGet to make it work. What you really want is a vxworks watchdog. Lookup wdCreate() and wdStart() in your vxworks docs, but be aware that your watchdog handler will be called from an ISR, and so standard ISR precautions should be taken (i.e. you will need a task to do the real work which should pend on a msgQ, or a semaphore that your watchdog handler triggers).

Actually now that I think about it, I believe that repeat and period also call the handler from an ISR, so technically the same restrictions apply there as well.

like image 159
Chris Desjardins Avatar answered Nov 22 '25 04:11

Chris Desjardins



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!