Shop OBEX P1 Docs P2 Docs Learn Events
SERIN Formatting — Parallax Forums

SERIN Formatting

KevSwannUKKevSwannUK Posts: 4
edited 2004-10-25 14:59 in BASIC Stamp
Hi All,

Can anyone help sed some light on this little data formatting problem I have. Basically I'm reciving some serial data from a GSM modem and I want to capture a specific part of the serial string.

Here is the string I am receiving...

+CMGR: “REC UNREAD”,”0146290800”,”98/10/01,18 :22 :11+00”,<CR><LF>ABCdefGHI OK

The section I need to get is the phone number 0146290800 only without the " symbol.. the best I can come up with is:

I know I want do do something like:

PNumber VAR Word
Serin RxD, B4800, [noparse][[/noparse]wait("+CMGR:"), wait(",") , SKIP 1, PNumber\???]

I'm not certain what I need to put after the PNumber. As the number always ends with a " how do I set this to be the end marker? It seems simple with any other character "*" for eample, but is """ valid?

Thanks in advance

Kevin

Comments

  • BorisBoris Posts: 81
    edited 2004-10-25 13:38
    PNumber\???

    if you know that the phone number is always 10 digits long, you can just put

    PNumber\10

    Basic stamp will stop recording digits/characters at 10 bytes.
  • KevSwannUKKevSwannUK Posts: 4
    edited 2004-10-25 13:45
    Thanks Boris... If only life was so simple...

    Unfortunatly the number can be any lenght from 8 to 16 numbers... Any other ideas?

    Regards



    Kev
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-10-25 14:40
    Have a look at the STR modifier of SERIN with the \Length and \End-Character parameters.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • KevSwannUKKevSwannUK Posts: 4
    edited 2004-10-25 14:44
    Jon, Thanks

    Yes that is what I have looked at, but is ... PNumber\"""] valid? i.e. can·" be used as an end character?

    Thanks

    Kev
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-10-25 14:54
    Try this little demo -- baud is set for use with the DEBUG terminal and a BS2:

    Quote           CON     34
    
    
    buffer          VAR     Byte(10)
    
    
    Main:
      DEBUG CLS, "Enter test string: "
      SERIN 16, $4054,
            [noparse][[/noparse]WAIT("+CMGR:"), WAIT(",") , SKIP 1, STR buffer\10\Quote]
      DEBUG CLS, STR buffer
      END
    


    It worked for me using your test input.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • KevSwannUKKevSwannUK Posts: 4
    edited 2004-10-25 14:59
    Excellent... ManyThanks
    roll.gif·
Sign In or Register to comment.