Jump to content

Protocol Scan Single Character in variable length string

Recommended Posts


We need to parse a text string to search for a single character within the string. This will then be used to trigger an SMS output. The incoming string is variable length with the last part also unknown content. The string header is known format. The terminator, (ETX) is 0xOD 0xOA, (CR LF).


We can successfully scan a properly, fully, defined string however we cannot figure out how to simply look for the first character for example find "A" in the start of the string or deal with a variable string.


Also once we see an "A" in the start of a string we still need to copy the entire string from the buffer to memory.


Any ideas or input is welcome......



Link to comment
Share on other sites



When you receive the string, do you convert 1 character to 1 element?  Is so, you can compare the first MI of teh buffer vector to the HEX or Decimal equivalent of an "A" (hex = 0x41, dec = 65).  Is the compare is true, trigger a bit, and on the positive transition of that bit, store the string into a separate vector.


You will have to create the second vector to be the length of the maximum amount of string space you will need.


Please let me know if this helps.

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...