Jump to content
Sign in to follow this  
active

Protocol Scan Single Character in variable length string

Recommended Posts

Hello...

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......

 

 

Share this post


Link to post
Share on other sites

Hello,

 

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.

Share this post


Link to post
Share on other sites

Thanks s.pratt

 

We went down that path after we posted on the forum we were trying to be too clever (not normally a problem) and use protocol scan but that only seems to work when matches complete string.

Share this post


Link to post
Share on other sites

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.

Guest
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.

Sign in to follow this  

×
×
  • Create New...