|
-
July 13th, 2005, 04:53 AM
#1
Parsing through data...
I have a buffer from an RS232 component that will be full of strings and 2 - 4 Byte numbers. Whats the best way to parse through this data, I was going to check that the data is valid (255 bytes of it) and have a pointer to the buffer which I will increment as I go checking the values and feeding them into a structure.... But Im not sure if Im heading for the best technique?
Does anyone know of a good way of doing this or perhaps a good article on something similar?
Thanks in advance for any tips
-
July 13th, 2005, 05:14 AM
#2
Re: Parsing through data...
depends on the structure and how the sender put the package together. Is the buffer you received a complete immage of the structure? If yes, and the structure does not contain any c++ class objects (like std::string) then just memcpy the buffer into the structure.
-
July 13th, 2005, 05:39 AM
#3
Re: Parsing through data...
The buffer is a complete image once all the data has been collected but I also need to verify this. The only types that are in the packet are bool, int and float and a few strings (no objects).
Im not exactly sure how Im going to tell the difference between many packets coming in and when they start / end.... They have a start and end charateur and the packets a fixed length so shouldnt be difficult.
Thanks Stober.
-
July 13th, 2005, 06:23 AM
#4
Re: Parsing through data...
Another problem you might encounter is Endian order if the data is transferred from one type of computer to another, such as between MS-Windows and IBM AIX unix.
-
July 13th, 2005, 07:46 AM
#5
Re: Parsing through data...
Yes, before memcpy'ing make sure byte ordering in the stream allows you to.
-
July 13th, 2005, 08:49 AM
#6
Re: Parsing through data...
Both sides are little endian.
Thanks people.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|