loading
 
RR_API
from United States  [60 posts]
14 year
Back to working with RR after getting other parts of my software operating. Will have something to share, real soon now.

In the RR_API::getvariable the 'max' parameter is used to determine the size of the RR_API::readMessage buffer. 'max' is the size limit of the 'results' buffer and has no relationship that I can see with parsing the incoming XML stream from RR. I think the parameter for readMessage should be "max + length of name + XML response characters" plus a little more.

Interestingly, 'max' is not used to limit the characters transfered to 'results" in the call to sscanf which could lead to a buffer overflow.

I found this when I reduced my buffer sizes to 32 bytes, which is more than sufficient to handle a COG_X value, and suddenly none of the variables were received except randomly.

Boy did this drive me nuts for an hour or so. I had all the variable working and then it all stopped working. I was that close to getting a neat wrapper around RR vars finished when it all quit. I'll be posting on my blog in the next day or so about what I have working.

Rud
Anonymous 14 year
Rud,

Good catch! That's true that the 'max' parameter was being misused in the C++ version of the GetVariable function. This has been corrected and instead we switch to using sscanf_s (save sscanf) so that the max command is now correctly used to limit the final result size instead of the readmessage size. We also standardized on 4096 as the total incoming readmessage size that the API will handle ... should be good for most applications. If you need more space increase the MAX_BUFFER_SIZE in the RR_API.h file.

Note that we also included a very primitive sscanf_s function for those using pre vc 2005.

You can see the changes in

http://www.roborealm.com/downloads/API.zip

Thanks for the tip!

STeven.
from United States  [60 posts] 14 year
STeven

Downloaded the files and they work well. There was one glitch with the  sscanf_s routine. The version check macro name should be:

#if _MSC_VER <= 1310

In VC2005 the name you had caused you version to compile which was a conflict with the existing version.

Glad to help.

Rud


This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index