|
-
Aug 24th, 2011, 05:38 AM
#1
Thread Starter
Hyperactive Member
How to extract this information
Hi I am reading from the serial port. The following is what I have picked up using ReadExisting() command on the serial port.
AT+CMGR=1
+CMGR: 1,,42
0791447758100650040C914477529628010000118032126411401A33D7396D2F83E8E872DB156497F12E72592ECE9BCD6633
OK
I want to extract
0791447758100650040C914477529628010000118032126411401A33D7396D2F83E8E872DB156497F12E72592ECE9BCD6633
I have managed that using this code
Code:
incoming_messages = incoming_messages.Replace(vbCrLf, "")
PDU_count = incoming_messages.Split(",,")
TxtEventLog.Text += vbCrLf & "PDU seperated: " & PDU_count(UBound(PDU_count))
PDU_count(UBound(PDU_count)) = PDU_count(UBound(PDU_count)).Remove(PDU_count(UBound(PDU_count)).Length - 2)
TxtEventLog.Text += vbCrLf & "PDU seperated: " & PDU_count(UBound(PDU_count))
It works except you see above there is the number 42 at the end of the CMGR line. That gets left on always.
I.e I end up with
420791447758100650040C914477529628010000118032126411401A33D7396D2F83E8E872DB156497F12E72592ECE9BCD6633
I thought about removing the first two characters of the string, but if that number is 3 digits then i have a problem again.
Looking back at this:
AT+CMGR=1
+CMGR: 1,,42
0791447758100650040C914477529628010000118032126411401A33D7396D2F83E8E872DB156497F12E72592ECE9BCD6633
OK
I need a more robust method of seperating the code out. I thought about searching for +CMGR: and removing the line or choosing the next line, but I dont know how to make sure that it will work whatever the number after the double comma is.
Has anyone got any suggestions
Thanks
Edit: for instance could I use the index of command, find a line o fthe +CMGR: and the ,, and find out how many digits after the ,,?
Last edited by youngnoviceinneedofh; Aug 24th, 2011 at 05:44 AM.
-
Aug 24th, 2011, 06:10 AM
#2
Re: How to extract this information
Why are you replacing the vbCrLf, that surely should be your delimiter and not the ",," ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|