Shop OBEX P1 Docs P2 Docs Learn Events
Help needed with SerIN & Byte Array for BS2 — Parallax Forums

Help needed with SerIN & Byte Array for BS2

ArchiverArchiver Posts: 46,084
edited 2001-04-08 00:44 in General Discussion
You have 26 bytes of usable variable space on your BS2. Obviously,
you can't fit 64 bytes of data into those 26 bytes. However, fear
not...Parallax hath provided.

Consider the following:

awaitData:
SERIN 16,baud,[noparse][[/noparse]WAIT "~1"]
SERIN 16,baud,200,gotData, [noparse][[/noparse]WAIT "~1", DEC c1, DEC c2, ..., DEC c17]

This will wait for "~1" to pass by in the input stream, then
look for one or a series of decimal numbers (0 - 9) and store the
value in c1, then look for another series and store it as c2, etc.
The "~2" will also be stored as one of the variables, but you can
figure out which one if you zero them all out first, then look
for the last non-zero variable, which should be 2.

You won't be storing the 'P' associated with each...but if it's
always there in the input stream, why bother storing it?

The timeout value shown (200) needs to be adjusted to match the interval
between bursts of data so the command can time out if all 16 commands
aren't presented, but before a new burst begins.

You'll also have to declare the c1...c17 variables:

c1 VAR BYTE
...
c17 VAR BYTE

I probably misunderstood something in your question, and if the data
rates are too high this may not work as written, but it's a starting
place.


Regards,

Steve

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-04-07 13:31
    On 7 Apr 01 at 19:44, Martin Zinaich wrote:

    > ...PS. Does the manual state the 25 bytes of variable space
    > somewhere.. I tried looking but I must have missed it....

    It's actually 26 (usable) bytes. Page 46 of BASIC Stamp Programming
    Manual 2.0. Highly recommended for your library, no matter where
    your library is.


    Regards,

    Steve
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-07 18:44
    I have a need to read input data on a BS2 via the Sub-d 9pin (S16).

    The problem I have is having enough space to capture what I need.
    I will be receiving up to 16 commands in one shot. These will come
    in as P1-P16, with ~1 starting and ~2 ending the commands. I can't
    seem to create a byte array large enough to handle this (64). I
    don't seem to understand the variable array space... it looks like I
    have plenty of Program space availabe..but I guess variable space is
    different? To make matters worse each command will include a
    CR/LF... so I'll see something like: ~1 cr/lf P2 cr/lf P12 cr/lf P9
    cr/lf ~2

    (up to 16 of the P commands plus the start and stop ~1 ~2)

    I know I can use the skip option, but with commands having a single
    digit and others having two, can I?? (p1 vs. p11).
    Can I make a large array for this like Indata(64), if so how.... can
    I use the "skip" command with the "wait" command?

    Any other ideas...?????

    Thanks in advance... I'm lost... [noparse]:)[/noparse]
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-08 00:44
    I think you have given me more than a good start!
    I think you understood the question great.
    There may be an issue or two, but this is
    a very good start... Thanks so much!!

    PS. Does the manual state the 25 bytes of variable
    space somewhere.. I tried looking but I must have
    missed it.... Also would you mind once I've played
    with this, if I run across something if I emailed you?
    (I wouldn't think of abusing your help, but it sounds
    like you have a good grasp on the BS2...)

    Thanks again...

    Original Message
    From: S Parkis [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=oukz7-w9FVIl5euFcAETVkJjuA2odVYQPMCkrB7B6JIAYHHo2wBC4IdtCfKo49OMfjXCdyPZr9XiQts]parkiss@e...[/url
    Sent: Saturday, April 07, 2001 2:42 AM
    To: martin@i...; basicstamps@yahoogroups.com
    Subject: Re: [noparse][[/noparse]basicstamps] Help needed with SerIN & Byte Array for BS2


    You have 26 bytes of usable variable space on your BS2. Obviously,
    you can't fit 64 bytes of data into those 26 bytes. However, fear
    not...Parallax hath provided.

    Consider the following:

    awaitData:
    SERIN 16,baud,[noparse][[/noparse]WAIT "~1"]
    SERIN 16,baud,200,gotData, [noparse][[/noparse]WAIT "~1", DEC c1, DEC c2, ..., DEC c17]

    This will wait for "~1" to pass by in the input stream, then
    look for one or a series of decimal numbers (0 - 9) and store the
    value in c1, then look for another series and store it as c2, etc.
    The "~2" will also be stored as one of the variables, but you can
    figure out which one if you zero them all out first, then look
    for the last non-zero variable, which should be 2.

    You won't be storing the 'P' associated with each...but if it's
    always there in the input stream, why bother storing it?

    The timeout value shown (200) needs to be adjusted to match the interval
    between bursts of data so the command can time out if all 16 commands
    aren't presented, but before a new burst begins.

    You'll also have to declare the c1...c17 variables:

    c1 VAR BYTE
    ...
    c17 VAR BYTE

    I probably misunderstood something in your question, and if the data
    rates are too high this may not work as written, but it's a starting
    place.


    Regards,

    Steve



    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Sign In or Register to comment.