sleepms bug in Linux API
4 years 8 months ago - 4 years 8 months ago #29534463
by vector
sleepms bug in Linux API was created by vector
I took the sample.cpp file provided with the Roboteq Linux API and changed line 49 from this:
to
I would have expected the program to pause for 3 seconds between the _ANAIN and the _GO commands. There was no pause whatsoever. It executed both commands in immediate succession and then disconnected and exited. Adding the requisite unistd.h header file and changing that line to:
does make it sleep for 3 seconds as it should.
I took a look at the code in RoboteqDevice.cpp and it says:
That should be:
Along with the corresponding function signature change in RoboteqDevice.h
sleepms(10);
to
sleepms(3000);
I would have expected the program to pause for 3 seconds between the _ANAIN and the _GO commands. There was no pause whatsoever. It executed both commands in immediate succession and then disconnected and exited. Adding the requisite unistd.h header file and changing that line to:
sleep(3);
does make it sleep for 3 seconds as it should.
I took a look at the code in RoboteqDevice.cpp and it says:
void sleepms(int milliseconds)
{
usleep(milliseconds / 1000);
}
That should be:
void sleepms(unsigned int milliseconds)
{
usleep(milliseconds * (unsigned int)1000);
}
Along with the corresponding function signature change in RoboteqDevice.h
Please Log in or Create an account to join the conversation.
4 years 8 months ago #29534468
by blake
Replied by blake on topic sleepms bug in Linux API
Please Log in or Create an account to join the conversation.
4 years 8 months ago #29534469
by vector
Replied by vector on topic sleepms bug in Linux API
Nope. I was using the one published last year. Thanks for letting me know! I'll go check it out.
Please Log in or Create an account to join the conversation.
4 years 8 months ago - 4 years 8 months ago #29534473
by vector
Replied by vector on topic sleepms bug in API
FYI, v2.0 of the API has the exact same bug.
Please Log in or Create an account to join the conversation.
Moderators: tonysantoni
Time to create page: 0.062 seconds