I wrote my own terminal program that reads from the serial port to read data from a microcontroller. Data is presented as follows:
0C82949>0D23949>0A75249> etc…
These are ASCII. Some things to note are that all elements start with >_0xx which is the header where xx is some chars such as >0C8 or >0D2 etc… this tells me what the rest of the data is such as if >0C8 is the speed of the car then 2949 holds the actual speed. The microcontroller writes the data really fast so at one time i can see 40 elements at a time. I want to quickly search this for an “>0C8” entry and only print out “>0C82949” out of the bunch:
an example if i only want 0D2:
Read from Serial Port: >0C82949>0D23949>0A75249>
Output: 0D23949
would anyone know how to do this?? I am aware that since it is so fast i would have to create threads which i can do, i am just not sure how to approach this issue for parsing. Any ideas would be greatly appreciated.
I am using Visual C++
You can parse the data and divide it on each
>character. Then create separate strings. For each string, just search for desired substring. You may usestrstrorCString::Findorstring::find.There is no need to create separate thread – the search operation is quite trivial and won’t take much of CPU.