Shop OBEX P1 Docs P2 Docs Learn Events
A newbie question (I hate that word...) — Parallax Forums

A newbie question (I hate that word...)

ArchiverArchiver Posts: 46,084
edited 2001-10-29 19:48 in General Discussion
I am TRYING to send serial data (simply) from the BS1 to the BS2, the trouble is
that it's not working. Please tell me if this is correct syntax for sending and
recieving and if this will work:
Sending the decimal number 45 from bs1 to bs2 at 300baud. BS1 waits one sec,
then sends....bs2 waits 5 sec for data. THIS DOESN"T WORK. What the heck am I
doing wrong? Any help is always appreciated...

'{$STAMP BS1}
PAUSE 1000
SEROUT 0, T300, ( #45 )
HIGH 7
END

'{$STAMP BS2}
databyte VAR BYTE
SERIN 0, 3313, 5000, nodata, [noparse][[/noparse]DEC databyte]
DEBUG DEC databyte
END

nodata:
HIGH 7
END



[noparse][[/noparse]Non-text portions of this message have been removed]

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-10-29 19:48
    >I am TRYING to send serial data (simply) from the BS1 to the BS2,
    >the trouble is that it's not working. Please tell me if this is
    >correct syntax for sending and recieving and if this will work:
    >Sending the decimal number 45 from bs1 to bs2 at 300baud. BS1 waits
    >one sec, then sends....bs2 waits 5 sec for data. THIS DOESN"T WORK.
    >What the heck am I doing wrong? Any help is always appreciated...
    >
    >'{$STAMP BS1}
    >PAUSE 1000
    >SEROUT 0, T300, ( #45 )
    >HIGH 7
    >END
    >
    >'{$STAMP BS2}
    >databyte VAR BYTE
    >SERIN 0, 3313, 5000, nodata, [noparse][[/noparse]DEC databyte]
    >DEBUG DEC databyte
    >END
    >
    >nodata:
    >HIGH 7
    >END
    >

    Hi Astro,

    The BS2 is left waiting for more data to arrive from the BS1. The
    DEC modifier can accept up to 5 bytes, or until a terminator
    character is received. There are a couple of ways to work it. On
    the BS1, you can send a terminator:
    SEROUT 0, T300, ( #45, 13 ) ' CR after data

    or if the BS1 is always going to send two bytes, then the BS2 could
    use the DEC2 modifier.
    SERIN 0, 3313, 5000, nodata, [noparse][[/noparse]DEC2 databyte]

    or, the BS1 could send one single byte, and the BS2 receive one byte:
    SEROUT 0, T300, (45) ' BS1 send byte 45
    SERIN 0, 3313, 5000, nodata, [noparse][[/noparse]databyte] ' BS2 receive byte 45
Sign In or Register to comment.