I have posted a question on the General C++ Programming forum, but since I don't understand the answer that was given to me, I understood that being a beginner, the answers will be more adapted to my level here.
I am currently working on an application receiving and sending data via serial port RS232.
I got a snippet in which the class stringbuf(typedef _stringbuf<char>)was used. According to what I understood at MSDN, a stringbuf object can save several strings, but maybe I did not understand well.
Any way, what I need is any class that would allows me to get save the serial data (10 bytes by 10, or 5 by 5, it doesn't matter), and then separate them in order to compare them one by one.
Any idea?
Thank you very much!!
(Please explain with simple words. :-)))
From what I understand you want to parse the data you get from the Serial port right?
A stringbuf should not be used to store data, so somewhere in your loop you should save it to a std::string object I would suggest a vector of string objects. From there you can do anything you would do with a normal string since that's what it will be.
Oh great - site 404'd when I was submitting
but I pretty much said what Computergeek01 said.
(( Although getting from the serial port to a std::string may not be directly possible - so
serial port -> char array[] first - then put that array in the vector as std::string has a conversion from char*))
guestgulkan brings up a valid concern which begs the question what lib are you using? Boost for instance will be designed around a different approach to this process then Win32 will for example. If we are to help steer you in the right direction it would help to know what that direction is.
Unfortunatly I can't phrase it better then Bazzy did without losing some of the meaning. But I can try, Data goes into your program through Streams to Buffers which hold your data until you save it to Variables
I still don't get it, do you have maybe a little example??
What I mean is that according to what you are saying (writing...), why cannot I use them for parsing?
I get the data, save it to variable and then check it byte byte? No?
You have it right, just make sure you're checking the variable not the stream byte by byte. Remeber even though the app you write will go super fast by your standards, the data is being read in at that same super fast speed (not actually but we won't cut it so close to the bone as to consider the south bridge verse the memory bus here), so you'll want to save that data so that you can work with it.