Shop OBEX P1 Docs P2 Docs Learn Events
Serial Data Formatting — Parallax Forums

Serial Data Formatting

ArchiverArchiver Posts: 46,084
edited 2003-09-07 19:44 in General Discussion
Hey everyone,



I have built a VB application which sends some user inputted data to the
stamp, and then the stamp does accordingly with it. My problem is I
don't know how to format data i.e. I have 2 times hrs&min that need to
be inputted and 8 checkboxes each with a different numerical value. So I
was wondering if I could just send two messages, 8 bytes each (does it
have to be only 8?). I think it would look like this:

01259010

0: ID command

1259: 12:59

0: am (1=pm)

1: checkbox numbers

0:End ID

Is this right? I'm having the hardest time trying to work on this
project because my family is in the middle of a move and we are staying
in an apartment waiting for our house to be finished,(it will be the
29th) the worst part is that all my stamp stuff is in some storage
warehouse so I can't test out my vb code. It would be much appreciated
if you could help me out.



Thanks

-Mike





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

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-09-07 15:43
    Yes, this should work.
    First decision: Are you sending Binary or 'Ascii'.
    I recommend 'Ascii', since you can see it, and
    testing will be easier.

    So: Sending ascii: VB
    Dim MyVBStr as STRING
    Dim MyHours as Long
    Dim MyMin as Long
    DIM IsPM as Long ' 1 == Is PM, 0 == AM
    Dim CheckBoxVal as BYTE


    MyVBStr = "0" & FORMAT(MyHours,"00") & _
    FORMAT(MyMin, "00") & FORMAT(IsPM, "0") & _
    CHR(CheckBoxVal)

    MSComm1.Output(MyVBStr)
    '**********************************************
    ' BS2 Side
    '**********************************************
    I9600 CON $54 + $4000
    MyVals VAR BYTE(8)
    MyHour VAR BYTE
    MyMin VAR BYTE
    MyBits VAR BYTE

    DIRL = %1111111 ' All outputs
    MainLoop:
    SERIN 16, I9600, [noparse][[/noparse]MyVals\8]
    MyHour = MyVals(1) - "0" * 10 + (MyVals(2) - "0")
    ' Above converts 2 ascii bytes "12" into stored
    ' variable value 12. The '- "0"' part converts
    ' ascii "0" into value 0.

    MyMin = MyVals(3) - "0" * 10 + (MyVals(2) - "0")
    MyBits = MyVals(7) ' Since passed as 'CHR', is good
    ' for direct copy...
    OUTL = MyBits
    GOTO MAINLOOP


    --- In basicstamps@yahoogroups.com, "Mike Dillon" <laxboy687@e...>
    wrote:
    > Hey everyone,
    >
    >
    >
    > I have built a VB application which sends some user inputted data
    to the
    > stamp, and then the stamp does accordingly with it. My problem is I
    > don't know how to format data i.e. I have 2 times hrs&min that need
    to
    > be inputted and 8 checkboxes each with a different numerical value.
    So I
    > was wondering if I could just send two messages, 8 bytes each (does
    it
    > have to be only 8?). I think it would look like this:
    >
    > 01259010
    >
    > 0: ID command
    >
    > 1259: 12:59
    >
    > 0: am (1=pm)
    >
    > 1: checkbox numbers
    >
    > 0:End ID
    >
    > Is this right? I'm having the hardest time trying to work on this
    > project because my family is in the middle of a move and we are
    staying
    > in an apartment waiting for our house to be finished,(it will be the
    > 29th) the worst part is that all my stamp stuff is in some storage
    > warehouse so I can't test out my vb code. It would be much
    appreciated
    > if you could help me out.
    >
    >
    >
    > Thanks
    >
    > -Mike
    >
    >
    >
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-09-07 19:44
    Thanks so much Allan.

    -Mike

    Original Message
    From: Allan Lane [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=0fF5GbZkmLDtLND8RdNQg-p7cbqcwCrgib83Ow289n-FqvL3AWAUOkkVG81VSJn26RxtcjK-Xg4me80QpGS29w-wKsNdyA]allan.lane@h...[/url
    Sent: Sunday, September 07, 2003 9:43 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: Serial Data Formatting

    Yes, this should work.
    First decision: Are you sending Binary or 'Ascii'.
    I recommend 'Ascii', since you can see it, and
    testing will be easier.

    So: Sending ascii: VB
    Dim MyVBStr as STRING
    Dim MyHours as Long
    Dim MyMin as Long
    DIM IsPM as Long ' 1 == Is PM, 0 == AM
    Dim CheckBoxVal as BYTE


    MyVBStr = "0" & FORMAT(MyHours,"00") & _
    FORMAT(MyMin, "00") & FORMAT(IsPM, "0") & _
    CHR(CheckBoxVal)

    MSComm1.Output(MyVBStr)
    '**********************************************
    ' BS2 Side
    '**********************************************
    I9600 CON $54 + $4000
    MyVals VAR BYTE(8)
    MyHour VAR BYTE
    MyMin VAR BYTE
    MyBits VAR BYTE

    DIRL = %1111111 ' All outputs
    MainLoop:
    SERIN 16, I9600, [noparse][[/noparse]MyVals\8]
    MyHour = MyVals(1) - "0" * 10 + (MyVals(2) - "0")
    ' Above converts 2 ascii bytes "12" into stored
    ' variable value 12. The '- "0"' part converts
    ' ascii "0" into value 0.

    MyMin = MyVals(3) - "0" * 10 + (MyVals(2) - "0")
    MyBits = MyVals(7) ' Since passed as 'CHR', is good
    ' for direct copy...
    OUTL = MyBits
    GOTO MAINLOOP


    --- In basicstamps@yahoogroups.com, "Mike Dillon" <laxboy687@e...>
    wrote:
    > Hey everyone,
    >
    >
    >
    > I have built a VB application which sends some user inputted data
    to the
    > stamp, and then the stamp does accordingly with it. My problem is I
    > don't know how to format data i.e. I have 2 times hrs&min that need
    to
    > be inputted and 8 checkboxes each with a different numerical value.
    So I
    > was wondering if I could just send two messages, 8 bytes each (does
    it
    > have to be only 8?). I think it would look like this:
    >
    > 01259010
    >
    > 0: ID command
    >
    > 1259: 12:59
    >
    > 0: am (1=pm)
    >
    > 1: checkbox numbers
    >
    > 0:End ID
    >
    > Is this right? I'm having the hardest time trying to work on this
    > project because my family is in the middle of a move and we are
    staying
    > in an apartment waiting for our house to be finished,(it will be the
    > 29th) the worst part is that all my stamp stuff is in some storage
    > warehouse so I can't test out my vb code. It would be much
    appreciated
    > if you could help me out.
    >
    >
    >
    > Thanks
    >
    > -Mike
    >
    >
    >
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]


    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.


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