Shop OBEX P1 Docs P2 Docs Learn Events
Split serial-incomming data into two variables. — Parallax Forums

Split serial-incomming data into two variables.

ArchiverArchiver Posts: 46,084
edited 2003-01-20 23:54 in General Discussion
Hi
Try to split serial-incoming data into two variables, just like it's
explained on page 314 in the BS2-book.

The program is just modified to work against the debug window. (win-
version)
If I write e.g., "Pos: 12345678" the numbers should end up in two
variables, but if I get anything at all, it's the wrong numbers
(Don't know where they come from)

Can somebody give me some clue how split serial-incoming data into
two variables.
Or how to best evaluate incoming data, both strings and numbers.
I have tried the line: If ID = 12 then …… but what about strings?

Thanks.
Stein_Frostad at mailcity dot com

' *********** Serin comm into two variables (Page 314 in BS2-book)

YOffset var Word
XOffset var Word

Start:
Serin 16,16468,[noparse][[/noparse]Wait("Pos: "),dec Xoffset,dec yOffset]
Debug ? Yoffset
Debug ? XOffset

Goto Start

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-01-19 14:45
    I'm writing this as I'm trying to eat breakfast and head out the door to a
    seminar, so I can't confirm this will work for you. Give it a shot....

    SERIN baud, pin, [noparse][[/noparse]WAIT ("Pos: "), DEC4 x, DEC4 y)]

    This counts on your input data being eight digits wide, with four digits for
    x and four digits for y.

    -- Jon Williams
    -- Parallax


    In a message dated 1/19/2003 7:03:55 AM Central Standard Time,
    Stein_Frostad@m... writes:

    > Hi
    > Try to split serial-incoming data into two variables, just like it's
    > explained on page 314 in the BS2-book.
    >
    > The program is just modified to work against the debug window. (win-
    > version)
    > If I write e.g., "Pos: 12345678" the numbers should end up in two
    > variables, but if I get anything at all, it's the wrong numbers
    > (Don't know where they come from)
    >
    > Can somebody give me some clue how split serial-incoming data into
    > two variables.
    > Or how to best evaluate incoming data, both strings and numbers.
    > I have tried the line: If ID = 12 then
  • ArchiverArchiver Posts: 46,084
    edited 2003-01-20 23:54
    Grate. You made the communication working, Jon. Jiiippppi.

    The Stamp works perfectly with Access Database (Visual Basic) also.
    Only drawback……this little BS2 program (under) is working greate on
    9600 baud against the debug window, but when I start up the VB-
    program, I can only use 2400 baud. Even 4800 baud is to fast.

    Do you have a last minute sudjestion for this leap of differences?

    yOffset var word
    xOffset var word
    BaudV con 16780 ` /16468 2400 baud/9600 baud.

    Start:
    Xoffset=0
    Yoffset=0

    Serin 16,BaudV,[noparse][[/noparse]Wait ("Pos: "),dec4 xOffset,dec4 yOffset]
    Pause 10
    Serout 16,baudV,[noparse][[/noparse]"From PC: X=",dec xOffset," Y=",dec yoffset]

    'Debug ? yOffset ` Use only in 9600 baud
    'Debug ? xOffset

    Goto Start
    ******************************
    Future stampers looking into communication between VB and BS2
    remember:
    -Stamp returns echo, What ever you send is returned (Can't be turned
    off). Can be used as a check that the stamp is hocked up correctly.
    -Stamp resets when you close/open the com port on the Computer. Put
    in the line serout 16,16780,[noparse][[/noparse]" Stamp Reset "] on top of stamp
    program. Then the VB-program detects this info, and you can program
    it to do the right thing.
    -It's hard to get the baud rate over 2400 between BS2 and VB. The
    debug window work in 9600.
    -Remember to turn off other serial com programs on your Pc.

    Thanks.
    Stein_Frostad at mailcity dot com


    --- In basicstamps@yahoogroups.com, jonwms@a... wrote:
    > I'm writing this as I'm trying to eat breakfast and head out the
    door to a
    > seminar, so I can't confirm this will work for you. Give it a
    shot....
    >
    > SERIN baud, pin, [noparse][[/noparse]WAIT ("Pos: "), DEC4 x, DEC4 y)]
    >
    > This counts on your input data being eight digits wide, with four
    digits for
    > x and four digits for y.
    >
    > -- Jon Williams
    > -- Parallax
    >
    >
    > In a message dated 1/19/2003 7:03:55 AM Central Standard Time,
    > Stein_Frostad@m... writes:
    >
    > > Hi
    > > Try to split serial-incoming data into two variables, just like
    it's
    > > explained on page 314 in the BS2-book.
    > >
    > > The program is just modified to work against the debug window.
    (win-
    > > version)
    > > If I write e.g., "Pos: 12345678" the numbers should end up in
    two
    > > variables, but if I get anything at all, it's the wrong numbers
    > > (Don't know where they come from)
    > >
    > > Can somebody give me some clue how split serial-incoming data
    into
    > > two variables.
    > > Or how to best evaluate incoming data, both strings and numbers.
    > > I have tried the line: If ID = 12 then
Sign In or Register to comment.