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

SPSTR question

ArchiverArchiver Posts: 46,084
edited 2004-07-02 16:48 in General Discussion
--- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
wrote:
> SPSTR was unintentionally omitted from the manual. As I frequently
> recommend, use the Help file as it is easier to distribute so it
> contains the latest information.
>
> Yes, SPSTR always starts writing at location 0, and its only
limitation
> is number of bytes; it does not look for a terminating character.
>
> -- Jon Williams

Sorry to beat a dead horse, but the only documentation I can find on
this command is in the BS2pCommands.pdf file from the Parallax
website. I can't find it anywhere else, and the references to it in
this file are limited. I also had just downloaded (what I thought)
was the most recent HELP file (that comes with the PBASIC stamp
editor, and it makes no reference to SPSTR). Are the files on the
Parallax website the most recent ones?

If I use

serin RxD, baud, [noparse][[/noparse]wait("ABC"), spstr N]

where 'N' is say, 16, how will the command deal with a string that is
only 10 characters? (i.e. will it pad the remaining spaces?) I am
not sure what the string lengths will be that I am getting with the
SERIN.

BTW, I would just test this myself, but my BS2p isn't here yet.

Thanks once again,

Ryan

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-07-02 15:25
    Let me clarify ... SPSTR is NOT a command, it is a serial input stream
    modifier. It redirects the serial input (specifed by the L parameter in
    bytes) to the Scratchpad, starting at location 0. You cannot force
    SPSTR to start writing at a different location.

    You must be careful when using SPSTR to specify the number of bytes you
    expect or something less. If you specify 16 bytes and only 10 come in,
    it will wait for six more. Like all tools, it may not be perfect for
    your requirement.

    BTW, the Help file has a search function. If you enter SPSTR into the
    search field you'll see that it shows up in five topics (all serial
    input functions). If you have the Version 2.1 Beta 1 editor, you have
    the latest help file (and editor and help file update will be available
    next week).

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




    Original Message
    From: LostboY [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=St8QGkgGNbQC7M6Ff-A0h53uvt5w94bijepuJd7mnitntyM9nMq6yPUwroR1My8VLO2CdMHigMeyRnkl]hangook21@y...[/url
    Sent: Friday, July 02, 2004 8:47 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] SPSTR question


    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > SPSTR was unintentionally omitted from the manual. As I frequently
    > recommend, use the Help file as it is easier to distribute so it
    > contains the latest information.
    >
    > Yes, SPSTR always starts writing at location 0, and its only
    limitation
    > is number of bytes; it does not look for a terminating character.
    >
    > -- Jon Williams

    Sorry to beat a dead horse, but the only documentation I can find on
    this command is in the BS2pCommands.pdf file from the Parallax
    website. I can't find it anywhere else, and the references to it in
    this file are limited. I also had just downloaded (what I thought)
    was the most recent HELP file (that comes with the PBASIC stamp
    editor, and it makes no reference to SPSTR). Are the files on the
    Parallax website the most recent ones?

    If I use

    serin RxD, baud, [noparse][[/noparse]wait("ABC"), spstr N]

    where 'N' is say, 16, how will the command deal with a string that is
    only 10 characters? (i.e. will it pad the remaining spaces?) I am
    not sure what the string lengths will be that I am getting with the
    SERIN.

    BTW, I would just test this myself, but my BS2p isn't here yet.

    Thanks once again,

    Ryan



    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.

    Yahoo! Groups Links







    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2004-07-02 15:46
    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > Let me clarify ... SPSTR is NOT a command, it is a serial input
    stream
    > modifier. It redirects the serial input (specifed by the L
    parameter in
    > bytes) to the Scratchpad, starting at location 0. You cannot force
    > SPSTR to start writing at a different location.
    >
    > You must be careful when using SPSTR to specify the number of bytes
    you
    > expect or something less. If you specify 16 bytes and only 10 come
    in,
    > it will wait for six more. Like all tools, it may not be perfect
    for
    > your requirement.


    Let me say I am amazed at how quickly I get answers to questions
    here. This is my first project using STAMPS, and the support is
    amazing. Thanks.

    Now, since this is my first project ever with STAMPS, forgive me for
    asking such basic questions, but I'm learning as I go...

    You are correct this probably isn't the best tool for my
    requirement. My problem is that I don't know what the best tool for
    my requirement is because I'm new to these tools. So let me rephrase
    my question by explaining what I am trying to do and see if any of
    you can point me (null pointer? [noparse];)[/noparse] in the right direction.

    I have a BS2 that is on a BOE, with the Red-i webserver attached to
    the appmod header. I also have the Emic text-to-speech module
    connected. What I am attempting to do (and seem very close to doing)
    is to have a webpage where I can input a sentence which in turn is
    read in by the BS2, and then sent to the EMIC. The end result being
    a webpage where I can type text that is then spoken by the Emic.

    I have all the code written and working- however I am using an array
    for my text string on the BS2, and after all the code I am limited to
    about 16 bytes (that is all the RAM space I have left. I am trying
    to find a way to get the text from the Red-i into either EEPROM (on a
    BS2) or scratch pad ram (BS2p)- so that I can hold a string of max
    length 64 bytes. I use a SERIN (on the STAMP) to get the text from
    the RED-i- *SO* is there a clean/nice way to get what I'm reading
    from the serin into either EEPROM space or Scratch Pad? I would use
    the SPSTR serial input stream modifier, but I don't know how long the
    string will be each time.

    Any suggestions?

    (How is that for a first project?!? [noparse];)[/noparse]

    Ryan
  • ArchiverArchiver Posts: 46,084
    edited 2004-07-02 15:53
    Just a follow-up. If you're using SPSTR with SERIN, you can use the
    Timeout capability to break free in the event of fewer characters
    arriving than you specified for SPSTR. Here's a little snipped to code
    that I just ran to confirm this (serial input is via DEBUG window):


    idx VAR Byte
    char VAR Byte

    Reset:
    DEBUG CLS, "Enter (4-character) passcode: "

    Main:
    SERIN 16, $40F0, 10000, No_Code, [noparse][[/noparse]SPSTR 4]
    DEBUG CLS, "Checking: "
    FOR idx = 0 TO 3
    GET idx, char
    DEBUG char
    NEXT
    END

    No_Code:
    DEBUG CLS, "Entry error."
    PAUSE 2000
    GOTO Reset


    Just make sure your timeout parameter gives your data plenty of time to
    arrive.

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



    Original Message
    From: Jon Williams
    Sent: Friday, July 02, 2004 9:25 AM
    To: basicstamps@yahoogroups.com
    Subject: RE: [noparse][[/noparse]basicstamps] SPSTR question


    Let me clarify ... SPSTR is NOT a command, it is a serial input stream
    modifier. It redirects the serial input (specifed by the L parameter in
    bytes) to the Scratchpad, starting at location 0. You cannot force
    SPSTR to start writing at a different location.

    You must be careful when using SPSTR to specify the number of bytes you
    expect or something less. If you specify 16 bytes and only 10 come in,
    it will wait for six more. Like all tools, it may not be perfect for
    your requirement.

    BTW, the Help file has a search function. If you enter SPSTR into the
    search field you'll see that it shows up in five topics (all serial
    input functions). If you have the Version 2.1 Beta 1 editor, you have
    the latest help file (and editor and help file update will be available
    next week).

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




    Original Message
    From: LostboY [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=bOBvMTqNL5LlZzQ2BlKqu-Vl-DkZvjBOq9tsK6qRfTcfsi_4fJc4Ey_6uJKE1cxIrbVntOfxlSmg]hangook21@y...[/url
    Sent: Friday, July 02, 2004 8:47 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] SPSTR question


    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > SPSTR was unintentionally omitted from the manual. As I frequently
    > recommend, use the Help file as it is easier to distribute so it
    > contains the latest information.
    >
    > Yes, SPSTR always starts writing at location 0, and its only
    limitation
    > is number of bytes; it does not look for a terminating character.
    >
    > -- Jon Williams

    Sorry to beat a dead horse, but the only documentation I can find on
    this command is in the BS2pCommands.pdf file from the Parallax
    website. I can't find it anywhere else, and the references to it in
    this file are limited. I also had just downloaded (what I thought)
    was the most recent HELP file (that comes with the PBASIC stamp
    editor, and it makes no reference to SPSTR). Are the files on the
    Parallax website the most recent ones?

    If I use

    serin RxD, baud, [noparse][[/noparse]wait("ABC"), spstr N]

    where 'N' is say, 16, how will the command deal with a string that is
    only 10 characters? (i.e. will it pad the remaining spaces?) I am
    not sure what the string lengths will be that I am getting with the
    SERIN.

    BTW, I would just test this myself, but my BS2p isn't here yet.

    Thanks once again,

    Ryan
  • ArchiverArchiver Posts: 46,084
    edited 2004-07-02 15:57
    The BASIC Stamp is a GREAT tool -- I was refering to SPSTR and how it
    works. I can't comment on the rest of your project as I've not used the
    Red-I web server myself (I have no interest in connecting
    microcontrollers to the Internet).

    You can use the timeout parameter with SERIN so that your SPSTR input
    doesn't hang. I just posted a simple demo that proves this.

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


    Original Message
    From: LostboY [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=GWdtR31BqfbEhBj7XrcachyjcuZOaE6pBBg4hETGS6J3A_FolflFAHpOclzen2V_yzh8H77CjXm5MOSoCQ]hangook21@y...[/url
    Sent: Friday, July 02, 2004 9:47 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: SPSTR question


    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > Let me clarify ... SPSTR is NOT a command, it is a serial input
    stream
    > modifier. It redirects the serial input (specifed by the L
    parameter in
    > bytes) to the Scratchpad, starting at location 0. You cannot force
    > SPSTR to start writing at a different location.
    >
    > You must be careful when using SPSTR to specify the number of bytes
    you
    > expect or something less. If you specify 16 bytes and only 10 come
    in,
    > it will wait for six more. Like all tools, it may not be perfect
    for
    > your requirement.


    Let me say I am amazed at how quickly I get answers to questions
    here. This is my first project using STAMPS, and the support is
    amazing. Thanks.

    Now, since this is my first project ever with STAMPS, forgive me for
    asking such basic questions, but I'm learning as I go...

    You are correct this probably isn't the best tool for my
    requirement. My problem is that I don't know what the best tool for
    my requirement is because I'm new to these tools. So let me rephrase
    my question by explaining what I am trying to do and see if any of
    you can point me (null pointer? [noparse];)[/noparse] in the right direction.

    I have a BS2 that is on a BOE, with the Red-i webserver attached to
    the appmod header. I also have the Emic text-to-speech module
    connected. What I am attempting to do (and seem very close to doing)
    is to have a webpage where I can input a sentence which in turn is
    read in by the BS2, and then sent to the EMIC. The end result being
    a webpage where I can type text that is then spoken by the Emic.

    I have all the code written and working- however I am using an array
    for my text string on the BS2, and after all the code I am limited to
    about 16 bytes (that is all the RAM space I have left. I am trying
    to find a way to get the text from the Red-i into either EEPROM (on a
    BS2) or scratch pad ram (BS2p)- so that I can hold a string of max
    length 64 bytes. I use a SERIN (on the STAMP) to get the text from
    the RED-i- *SO* is there a clean/nice way to get what I'm reading
    from the serin into either EEPROM space or Scratch Pad? I would use
    the SPSTR serial input stream modifier, but I don't know how long the
    string will be each time.

    Any suggestions?

    (How is that for a first project?!? [noparse];)[/noparse]

    Ryan



    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.

    Yahoo! Groups Links







    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2004-07-02 16:38
    Hi Ryan,

    If the data does not come in too fast, as for example from a user
    typing, the Stamp can capture the string of unknown length in program
    loop, one character at a time.

    DO
    SERIN 0,sbaud,[noparse][[/noparse]char]
    PUT idx,char
    idx=idx+1
    LOOP UNTIL char=CR

    That sort of thing can be expanded to allow for all sorts of
    character filtering, backspace handling, timeouts, alternate
    termination characters etc. It is all a matter of having enough time
    between chars to do the processing. Sometimes you can set an
    inter-character pacing delay on the other side.

    -- Tracy




    >--- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    >wrote:
    >> Let me clarify ... SPSTR is NOT a command, it is a serial input
    >stream
    >> modifier. It redirects the serial input (specifed by the L
    >parameter in
    >> bytes) to the Scratchpad, starting at location 0. You cannot force
    >> SPSTR to start writing at a different location.
    >>
    >> You must be careful when using SPSTR to specify the number of bytes
    >you
    >> expect or something less. If you specify 16 bytes and only 10 come
    >in,
    >> it will wait for six more. Like all tools, it may not be perfect
    >for
    >> your requirement.
    >
    >
    >Let me say I am amazed at how quickly I get answers to questions
    >here. This is my first project using STAMPS, and the support is
    >amazing. Thanks.
    >
    >Now, since this is my first project ever with STAMPS, forgive me for
    >asking such basic questions, but I'm learning as I go...
    >
    >You are correct this probably isn't the best tool for my
    >requirement. My problem is that I don't know what the best tool for
    >my requirement is because I'm new to these tools. So let me rephrase
    >my question by explaining what I am trying to do and see if any of
    >you can point me (null pointer? [noparse];)[/noparse] in the right direction.
    >
    >I have a BS2 that is on a BOE, with the Red-i webserver attached to
    >the appmod header. I also have the Emic text-to-speech module
    >connected. What I am attempting to do (and seem very close to doing)
    >is to have a webpage where I can input a sentence which in turn is
    >read in by the BS2, and then sent to the EMIC. The end result being
    >a webpage where I can type text that is then spoken by the Emic.
    >
    >I have all the code written and working- however I am using an array
    >for my text string on the BS2, and after all the code I am limited to
    >about 16 bytes (that is all the RAM space I have left. I am trying
    >to find a way to get the text from the Red-i into either EEPROM (on a
    >BS2) or scratch pad ram (BS2p)- so that I can hold a string of max
    >length 64 bytes. I use a SERIN (on the STAMP) to get the text from
    >the RED-i- *SO* is there a clean/nice way to get what I'm reading
    >from the serin into either EEPROM space or Scratch Pad? I would use
    >the SPSTR serial input stream modifier, but I don't know how long the
    >string will be each time.
    >
    >Any suggestions?
    >
    >(How is that for a first project?!? [noparse];)[/noparse]
    >
    >Ryan
  • ArchiverArchiver Posts: 46,084
    edited 2004-07-02 16:48
    --- In basicstamps@yahoogroups.com, Tracy Allen <tracy@e...> wrote:
    > Hi Ryan,
    >
    > If the data does not come in too fast, as for example from a user
    > typing, the Stamp can capture the string of unknown length in
    program
    > loop, one character at a time.
    >
    > DO
    > SERIN 0,sbaud,[noparse][[/noparse]char]
    > PUT idx,char
    > idx=idx+1
    > LOOP UNTIL char=CR
    >
    > That sort of thing can be expanded to allow for all sorts of
    > character filtering, backspace handling, timeouts, alternate
    > termination characters etc. It is all a matter of having enough
    time
    > between chars to do the processing. Sometimes you can set an
    > inter-character pacing delay on the other side.
    >
    > -- Tracy


    Actually, I can get the string into the Red-i, and it will be fed to
    the stamp directly from the memory of the Red-i- Could I mess with
    the baud to slow down the communication to give the Stamp time to
    deal with a stream that is continually arriving?

    I have been thinking about how to get the chars one at a time for
    this very reason, but I don't have any control over how the Red-i
    sends the information (I don't think).

    The stamp sends a SEROUT command that basically says 'feed me that
    particular variable', and then the stamp needs a SERIN to read in
    what the Red-i sends.

    Ryan
Sign In or Register to comment.