datta016
June 10th, 2009, 11:28 AM
Hey everyone,
I wasn't too sure where to post this, so I figured General Topics would be a good start. I'm relatively new to vxWorks and RTOS in general. I have a quick question concerning nanosleep() in vxWorks. For some reason I just can't get it to work. I also can't find any examples of its usage through google (which was a shock, I'm sure I'm just not searching correctly).
All I am trying to do is set up the function in order to delay my task by 1 second (I'm trying to venture into POSIX commands as I am already familiar with taskDelay, for instance).
I am using #include <time.h> as the library (I think this is the correct one?). Aside from that I am pretty sure I am just screwing up the setup of the function. Here it is:
struct timespec nsTime;
nsTime.tv_sec = 1;
nsTime.tv_nsec = 0;
int nanosleep(nsTime, NULL);
/*Below this point is the code for the task I want delayed*/
When I attempt to compile I am presented with the following errors:
-warning: left-hand operand of comma has no effect
-error: initializor expression list treated as compound expression
-warning: unused variable 'nanosleep'
Any help would be great. Thank you in advance!
I wasn't too sure where to post this, so I figured General Topics would be a good start. I'm relatively new to vxWorks and RTOS in general. I have a quick question concerning nanosleep() in vxWorks. For some reason I just can't get it to work. I also can't find any examples of its usage through google (which was a shock, I'm sure I'm just not searching correctly).
All I am trying to do is set up the function in order to delay my task by 1 second (I'm trying to venture into POSIX commands as I am already familiar with taskDelay, for instance).
I am using #include <time.h> as the library (I think this is the correct one?). Aside from that I am pretty sure I am just screwing up the setup of the function. Here it is:
struct timespec nsTime;
nsTime.tv_sec = 1;
nsTime.tv_nsec = 0;
int nanosleep(nsTime, NULL);
/*Below this point is the code for the task I want delayed*/
When I attempt to compile I am presented with the following errors:
-warning: left-hand operand of comma has no effect
-error: initializor expression list treated as compound expression
-warning: unused variable 'nanosleep'
Any help would be great. Thank you in advance!