06-16-2012 12:12 PM
Hi Everyone in the Forum,
I have an instrument hwich is used to measure some gas concentartion that outputs a serial message that looks like this
2007-03-12 11:37:14 MDT,0x00000001,NH3,0.46,0.00,ppmm,21%,5.0,11,0,0,0
or
2007-03-12 11:37:22 MDT,0x00000001,NH3,0.41,0.00,ppmm,21%,5.0,11,0,0,0
I parse some of these characters, convert to numbers and plotthem in real time. For example the 21% is signal strength which I have to plot in real time using labview. Now sometime the instrumnet does not output the whole string completely, and maybe misses half the line. I would like to perfrom a position sensitive checksum on teh string to make sure it is complete and correct and of not reject that line. I tried to use CRC16 but everytime it gives me a 4 digits and characters such as e.g, F415 or soemtimes only digits e.g 7014, I DO NOT KNOW HOW TO INTERPRET THESE CHARACTERS. Appreciate if anybody can give me a hint or tell me how to use the checkum ( or which one) to reject imcomplete strings.
Solved! Go to Solution.
06-16-2012 12:26 PM
A CRC is only useful to verify a transmision was succesful. It works just like a parity. It needs to be added to the message by the sender and then verified by the receiver. So in short, the CRC is not going to help you here. It appears that the data is separated by commas. Maybe you can count how many commas are in the message to verify you have all of the message parameters.
06-16-2012 12:46 PM
Thanks. Counting commas may work. I will give it a try.
06-16-2012 05:12 PM
I would look into why you are not getting the entire response.
Is there some handshaking problem?
Are you no allowing enought time for the instrument to respond?
etc. etc.
Anything else is a kludge which masks the real problem.
06-16-2012 05:26 PM
I am afraid I have no control of how the instrument is outputting the serial string. There is a fixed integartion time and at that interval it outputs this string. Every once in a while ( maybe after every 10 to 20) at irregular intervals, an incomplete string comes out. Ideally I should send it back to he manufacturer but I am getting it ready for field testing in near future and needed a quick fix. I am positive the method of counting commas would work for now. Thanks for your thoughts anyways..
06-16-2012 08:27 PM
I was thinking about this as well. The counting of commas is really a kludge. I was curious if the device has a termination character at the end of a message. If it does, then you can setup the port to automatically look to that termination character. The other simple option might be to simply wait a little bit longer. Serial ports are slow after all.
06-16-2012 08:35 PM