Click here to Skip to main content
15,878,748 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
i have the information as shown below.
I have to parse the DATA PART that i will get from a machine and fill the values like Rinse mode,status of machine....
I will get data on Com Port,i have to do it in c++.
I have written the code to open the com port and send Data demand(command).
Can anyone help me to suggest how to do the parsing?


Data format
・ All data isASCII character code without checksumand CR.
・ Range ofMachineNumber start from0000 to 9999
・ If there is no top digit at data part, itwill be zero suppression and put space to fill it.
・ Calculate sum total from top till before checksum (1bite unit), then recognize this
complement of 1 as checksum.
・ Finish of format isCR Hexadecimal: OD


Data demand(command)
   CM"      "00"         Checksum       CR
(2 bite)   (2 bite)



Monitor data(response)
"RE"              "00"          MachineNumber    Data part
(2 bite)         (2 bite)         4bite            128 byte


Parameter              Data          byte               Unit              Status
Status of machine       #             1
Rinsemode               #             1
Bypass                  #             1
Dialysate flow         ###            3                      
Treated blood volume  ##.##           5  
W+B conductivity       ##.#           4  
Posted
Comments
pasztorpisti 30-Aug-12 8:02am    
Bite? That data structure seems to be quite aggressive...

1 solution

Create a structure consisting of all data items in the response, with the correct field sizes. You can then read the response into this structure, and pick out any of its data items.

HTH
 
Share this answer
 
Comments
Tarun Batra 30-Aug-12 8:06am    
Thanks for the reply sir...i have some doubts please explain them when i will get data how to reach the data part,as u can see in Monitor data(response) we have 6bytes before the data part start.
ChandraRam 30-Aug-12 8:10am    
Create your data structure to include the _complete_ response (including the "header" information), even if you do not want to use them further.

So, your structure should start with:
Type - 2 bytes (to store the "RE")
Flag - 2 bytes (not sure what this data is since you do not mention that)
MachineNumber - 2 bytes
Status - 1 byte
....
and so on.

HTH
Tarun Batra 30-Aug-12 8:15am    
Sir as all the info i have i have put it in the ques,according to "Data format" what do u think all data will be in ASCII Format? How will i take data in "Treated blood volume" as it is 5 bytes,sorry for silly ques i am a newbie and never done parsing before....
ChandraRam 30-Aug-12 8:17am    
I have no idea what your data is like - you mention in your question that it is all ASCII, so it should be a matter of just reading it as strings, right? Why don't you put it into the structure and read it to see what you actually get?
Tarun Batra 30-Aug-12 8:30am    
Sir i am confused how to take 5 byte data can u just tell through pseudo code?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900