This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

deciphering the sms response Keil oriented,the string manipulations

(using a phone as a modem gsm).Avoiding the problems of delays,AT gramathic having a lucky of using textmode,I waiting a string of only 4 numbers,but I receive also of course a lot information as sender number,time,..the "okeys"back from the phone etc.I hear that this is a question of strings conversions.I can not just compare the response with a previous stored response because after a string 4 numbers are received I need to decode those numbers(converting to integer) and read each and every one of them independent(I can not compare 9999 "posibles commands")
-how can I extract those 4 numbers(the only text)and avoid all the other unpleasent data that is coming on uart
maybe you have few examples,recomended functions or something else

  • This has nothing specifically to do with the 8051 nor Keil - it is a standard 'C' text parsing exercise.

    The "preamble" giving the sender number, etc, is in a standard format with well-defined delimiters between the elements.
    So you just need to "walk" through those elements - and what follows them must be your application-specific text!

    Or, perhaps, you could start at the end of the response and work backwards to the start of your application-specific text!

    Converting the digit characters from a text string into a numeric value is trivial...

  • converting digit caracters from the string into a numeric value...of course... you sugest "start at the end of the response and work backwards to the start of your application-specific text!"
    because the information on the received sms string is at the end of the string text (the 4 caracters)
    But given the bugs with function for string conversions we've been seing on Keil like atoi,strtol,atof and the others,Im asking to the experts for a most robust way,or at last if you where in my place:how you should avoid those conversions bugs and extract the 4 caracters,or use others functions,.."text parsing exercise"

  • I really can't see this as an exercise. Stripping a response string into the individual fields and picking up the relevant information is a quite trivial operation.

    Scanning from the start has the big advantage that the processor may throw away irrelevant information on-the-fly which may possibly reduce the required buffer sizes. I normally use a state machine and work character for character through the data.

    It takes time for the tranfer of serial data because of the baudrate. Processing the data while it arrives means that you can know the result a the same moment as you get the last character of the line.

    I work with the ARM tools, not the C51 tools. Must have missed anything about any bugs...