Shop OBEX P1 Docs P2 Docs Learn Events
SEROUT, DATA and STR question — Parallax Forums

SEROUT, DATA and STR question

daviddrakedaviddrake Posts: 20
edited 2005-04-28 15:46 in BASIC Stamp
I am using the SEROUT command, with some rather long strings, such as 28 bytes in length. Can the SEROUT properly understand the following:?

test DATA 1,2,3,4,5 '' fake data

SEROUT kout,baud, [noparse][[/noparse]STR test\5]

Or will this only work with byte arrays and so require the transfer of the "test" contents to a byte array?


Your help is appreciated!

David Drake

Comments

  • daviddrakedaviddrake Posts: 20
    edited 2005-04-22 21:12
    ...And also a possible workaround might be to transfer the data to the scratchpad ram. The SPSTR can be used for SERIN, but I haven't been able to make it work for SEROUT. Options?

    David Drake
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-22 21:18
    David,

    ·· Probably what you·will have to do is read your data from the EEPROM and send it out to the serial port 1 byte at a time.· If you do this within a loop it should work for you.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • daviddrakedaviddrake Posts: 20
    edited 2005-04-27 22:32
    Yes, reading a byte at a time from DATA and sending it to serout did work. Thanks for the input. It would be great in the future if serout would work with spstr like serin.

    TNX -DD
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-27 22:53
    David,

    ·· I probably made more work for you, which was not my intention.· Re-reading the original post, I was thinking, if you're using the SPRAM for the data, there's no need to write it to EEPROM before sending it out.· You can do a loop and get it one character at a time from the SPRAM just the same as you could from the EEPROM.· Sorry if we were on different topics.· I wasn't clear on whether you are or aren't using the SPRAM.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-04-27 23:28
    "SPRAM" meaning Scratch Pad RAM, I presume. With Flash ROM, EEPROM, and RAM, we probably have enough acronyms. "Scratch Pad" would have been sufficient.
  • daviddrakedaviddrake Posts: 20
    edited 2005-04-28 00:15
    In this case the data are known text strings at the time of compilation, so reading from the DATA is perfectly fine. You are right, if it was variable data it could have come right from the scratch pad.
    DD
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-28 00:36
    Since you're sending from DATA statements, you might consider storing them as z-strings so that you can use a simple subroutine to send any length string.· For example:

    Msg1··· DATA··· "Parallax rocks!", 0
    Msg2··· DATA··· "The BASIC Stamp", CR, "Embedded control made simple!", 0


    You can send either string with this subroutine:

    Send_Str:
    · DO
    ··· READ eeAddr, char
    ··· eePntr = eePntr + 1
    ··· IF (char = 0) THEN EXIT
    ··· SEROUT SPin, Baud, [noparse][[/noparse]char]
    · LOOP
    · RETURN


    Here's how you send a specific string:

    Main:
    · eePntr = Msg1
    · GOSUB Send_Str


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-28 03:20
    allanlane5 said...
    "SPRAM" meaning Scratch Pad RAM, I presume. With Flash ROM, EEPROM, and RAM, we probably have enough acronyms. "Scratch Pad" would have been sufficient.
    Allan,

    ·· Anyone using the SPSTR command should know what SPRAM is.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-04-28 13:06
    Sorry about that. I just hadn't seen "SPRAM" used as an acronym before, and apparently I was in a cranky mood. It was definitely a good point that scratch-pad RAM could be used that way.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-28 15:46
    Allan,

    ·· No biggie, I will endeavor to be more clear in my posts.· Thanks for your concern and input.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.