Shop OBEX P1 Docs P2 Docs Learn Events
SPSTR command — Parallax Forums

SPSTR command

ArchiverArchiver Posts: 46,084
edited 2003-10-21 17:05 in General Discussion
I have a 8 byte string coming into the serialin. I can't seem to get
serialin to read 4 bytes then 4 more bytes. Does anyone have an
example of the SPSTR (BS2P & PE)command handy. Can it handle varible
length strings? After parsing do you have to set the ram back to
zeros?
Thanks,
Paul

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-10-21 15:16
    SPSTR works with a fixed-length setting. The SPRAM will only change if
    you use the SPSTR modifier again or change the values manually. That
    said, if you have enough standard variable space, you can use the STR
    modifier to accept the data:

    buffer VAR Byte(8)

    Get_Data:
    SERIN Spin, Baud, [noparse][[/noparse]STR buffer\8]

    Note that the STR modifier lets you specify and ending character
    parameter so you can accept fewer bytes that specified in the length
    parameter.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office




    Original Message
    From: Paul [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=2Vj_zqZYPdGEtvJMbmPd9-ujSwlNPwxELR30TpUx23d7kiwmw_i_OhGDlqZl8gh_xChhDtGN6F0]prcoy@y...[/url
    Sent: Tuesday, October 21, 2003 8:27 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] SPSTR command


    I have a 8 byte string coming into the serialin. I can't seem to get
    serialin to read 4 bytes then 4 more bytes. Does anyone have an
    example of the SPSTR (BS2P & PE)command handy. Can it handle varible
    length strings? After parsing do you have to set the ram back to
    zeros?
    Thanks,
    Paul


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2003-10-21 17:05
    >I have a 8 byte string coming into the serialin. I can't seem to get
    >serialin to read 4 bytes then 4 more bytes. Does anyone have an
    >example of the SPSTR (BS2P & PE)command handy. Can it handle varible
    >length strings? After parsing do you have to set the ram back to
    >zeros?
    >Thanks,
    >Paul

    Hi Paul,

    serin 8,16884,10000,nodata,[noparse][[/noparse]wait("$GPRMC"),spstr 61]


    SPSTR can receive variable length strings, but you do have to know
    the length of the string in advance. 61 in the example. The data
    captured always starts at location 0 in the scratchpad RAM. So if
    you have SPSTR 4, SPSTR 4, that won't work, because the second string
    will overwrite the first. You have to do it as SPSTR 8. The data
    captured stays there until you PUT something else over it, or do
    another SPSTR, or reset the Stamp (which rezeros all scratchpad
    locations).

    -- Tracy
Sign In or Register to comment.