Menu

Topic-icon sleepms bug in Linux API

More
2 months 1 week ago - 2 months 1 week ago #29534463 by vector

I took the sample.cpp file provided with the Roboteq Linux API and changed line 49 from this:

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.

More
2 months 1 week ago #29534468 by blake

We published an updated API at the end of last week, it is labelled Windows/Linux API 2.0 (see attachment). Is this what you are using?

Attachments:

Please Log in or Create an account to join the conversation.

More
2 months 1 week ago #29534469 by vector

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.

More
2 months 1 week ago - 2 months 1 week ago #29534473 by vector

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.190 seconds
Go to top