Shop OBEX P1 Docs P2 Docs Learn Events
hex code! — Parallax Forums

hex code!

ArchiverArchiver Posts: 46,084
edited 2003-05-30 19:21 in General Discussion
Am wondering if these two statements r the same


serout 16,16468 [noparse][[/noparse]hex 12]

serout 16,16468,[noparse][[/noparse]$c]

Thanks in anticipation

Sumana Garikipati

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-05-28 22:48
    No. The first sends the character "C" (ASCII 67). The second sends ASCII
    12. Keep in mind that the serial formatters DEC, HEX, and BIN (as well as the
    "I" and "S" versions) are numeric-to-string (character) convertors.

    -- Jon Williams
    -- Parallax

    In a message dated 5/28/2003 1:57:24 PM Central Standard Time,
    sumanagarikipati@y... writes:

    > Am wondering if these two statements r the same
    >
    >
    > serout 16,16468 [noparse][[/noparse]hex 12]
    >
    > serout 16,16468,[noparse][[/noparse]$c]
    >
    > Thanks in anticipation
    >
    > Sumana Garikipati



    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-05-29 03:09
    Sir,

    Thanks for the reply.So how do I send the hex numbers
    then??.For example to reset a bluetooth Module I need to send
    a set of hex commands eg: reset : 01 03 0c 00 total of 4 bytes.

    which one shd I use?? $ or hex???

    Thanks in anticipation

    Sumana Garikipati




    --- In basicstamps@yahoogroups.com, jonwms@a... wrote:
    > No. The first sends the character "C" (ASCII 67). The second
    sends ASCII
    > 12. Keep in mind that the serial formatters DEC, HEX, and BIN (as
    well as the
    > "I" and "S" versions) are numeric-to-string (character) convertors.
    >
    > -- Jon Williams
    > -- Parallax
    >
    > In a message dated 5/28/2003 1:57:24 PM Central Standard Time,
    > sumanagarikipati@y... writes:
    >
    > > Am wondering if these two statements r the same
    > >
    > >
    > > serout 16,16468 [noparse][[/noparse]hex 12]
    > >
    > > serout 16,16468,[noparse][[/noparse]$c]
    > >
    > > Thanks in anticipation
    > >
    > > Sumana Garikipati
    >
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-05-29 15:18
    Jon, Ok I'm thick. Why does the first one give the character "C".




    --- In basicstamps@yahoogroups.com, jonwms@a... wrote:
    > No. The first sends the character "C" (ASCII 67). The second
    sends ASCII
    > 12. Keep in mind that the serial formatters DEC, HEX, and BIN (as
    well as the
    > "I" and "S" versions) are numeric-to-string (character) convertors.
    >
    > -- Jon Williams
    > -- Parallax
    >
    > In a message dated 5/28/2003 1:57:24 PM Central Standard Time,
    > sumanagarikipati@y... writes:
    >
    > > Am wondering if these two statements r the same
    > >
    > >
    > > serout 16,16468 [noparse][[/noparse]hex 12]
    > >
    > > serout 16,16468,[noparse][[/noparse]$c]
    > >
    > > Thanks in anticipation
    > >
    > > Sumana Garikipati
    >
    >
    >
    > [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/



    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-05-29 17:05
    Because the HEX formatter is used. The formatters BIN, DEC, and HEX actually
    perform a numeric to string (text) conversion.

    Try this is your editor:

    value VAR Byte

    Main:
    value = 12
    DEBUG DEC value, CR
    DEBUG HEX value

    Note that the DEBUG screen requires conversion to text format -- unless
    you're sending a specific control character.

    -- Jon Williams
    -- Parallax

    In a message dated 5/29/2003 10:07:02 AM Central Standard Time,
    porter.sadler@s... writes:

    > Jon, Ok I'm thick. Why does the first one give the character "C".
    >
    >
    > --- In basicstamps@yahoogroups.com, jonwms@a... wrote:
    > >No. The first sends the character "C" (ASCII 67). The second
    > sends ASCII
    > >12. Keep in mind that the serial formatters DEC, HEX, and BIN (as
    > well as the
    > >"I" and "S" versions) are numeric-to-string (character) convertors.
    > >
    > >-- Jon Williams
    > >-- Parallax
    > >
    > >In a message dated 5/28/2003 1:57:24 PM Central Standard Time,
    > >sumanagarikipati@y... writes:
    > >
    > >>Am wondering if these two statements r the same
    > >>
    > >>
    > >>serout 16,16468 [noparse][[/noparse]hex 12]
    > >>
    > >>serout 16,16468,[noparse][[/noparse]$c]
    > >>
    > >>Thanks in anticipation
    > >>
    > >>Sumana Garikipati



    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-05-30 19:21
    Sumana,

    serout 16,16468,[noparse][[/noparse]$01,$03,$0c,$00]

    will send the reset sequence. The following specifies the same
    numbers in either decimal or binary:

    serout 16,16468,[noparse][[/noparse]1,3,12,0] ' numbers written as decimal
    serout 16,16468,[noparse][[/noparse]%1,%11,%1100,%0] ' written as binary

    The numbers sent by SEROUT are the same in all three forms. It is
    just the notation that is different.

    > > > Am wondering if these two statements r the same
    >> >
    >> >
    >
    > > > serout 16,16468 [noparse][[/noparse]hex 12]
    >> >
    >
    > > > serout 16,16468,[noparse][[/noparse]$c]

    No, as Jon said (and someone else questioned) the first one sends out
    the ascii character "c", because the number 12 in decimal (=$c in
    hex, =%1100 in binary) is converted to a string (ascii 67 = "c") by
    the HEX modifier. So on a display screen you see the letter "c".

    The second form, sending just $c with no modifier sends the actual
    value, $c in hex, which is the same as the binary %1100, which is
    "12" in decimal. If you send that to a display screen, you might see
    a funny character, or maybe your screen would go blank, because, in
    ascii, 12 is a control character that usually means "form feed".

    -- Tracy




    >Sir,
    >
    > Thanks for the reply.So how do I send the hex numbers
    >then??.For example to reset a bluetooth Module I need to send
    >a set of hex commands eg: reset : 01 03 0c 00 total of 4 bytes.
    >
    >which one shd I use?? $ or hex???
    >
    >Thanks in anticipation
    >
    >Sumana Garikipati
    >
    >
    >
    >
    >--- In basicstamps@yahoogroups.com, jonwms@a... wrote:
    >> No. The first sends the character "C" (ASCII 67). The second
    >sends ASCII
    >> 12. Keep in mind that the serial formatters DEC, HEX, and BIN (as
    >well as the
    >> "I" and "S" versions) are numeric-to-string (character) convertors.
    >>
    >> -- Jon Williams
    >> -- Parallax
    >>
    >> In a message dated 5/28/2003 1:57:24 PM Central Standard Time,
    >> sumanagarikipati@y... writes:
    >>
    >
    > > > Am wondering if these two statements r the same
    >> >
    >> >
    >
    > > > serout 16,16468 [noparse][[/noparse]hex 12]
    >> >
    >> > serout 16,16468,[noparse][[/noparse]$c]
    > > >
    >> > Thanks in anticipation
    >> >
    >> > Sumana Garikipati
    >>
    >>
    >>
    >> [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.