Shop OBEX P1 Docs P2 Docs Learn Events
Checksum --- again... — Parallax Forums

Checksum --- again...

ArchiverArchiver Posts: 46,084
edited 2003-12-07 10:23 in General Discussion
Hello Stampers,
I am back on the checksum issue again.

I am sending data from a stamp to a pc and receiving the data into VB6.
When I send the data, I send it as ascii tect, and I have the data mixed up
as bytes, words and 3 bytes together which are compiled as a 6 digit number
at the pc.

I want to send a checksum byte to the pc at the end of the data stream,
which is easy, but I want to sent a checksum value which is the sum of the
bytes when they are sent as ascii characters using the dec formatter at the
stamp. For example, instead of sending the word value of 48332, and simplt
checksumming the word value or the 2 bytes, I want to checksum the value of
the bytes "4", "8", "3", "3" and "2" as they are sent. I want to be able to
checksum bytes and words.

Is this possible? I wish to send the data as ascii because it is reliable
when sent thru a modem, as the data cant get mixed up with control codes
etc.

Any ideas would be appreciated.

Cheers.
Chris Anderson
Western Australia

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-12-06 11:19
    Hi Chris,

    Yes it is possible. You could try something like this:

    n var byte ' universal counter
    CurrentValue var word ' current value
    Checksum var byte ' checksum byte

    Checksum = 0

    FOR n = 0 TO 4
    Checksum = Checksum ^ ((CurrentValue DIG n) + 48)
    NEXT

    The DIG operator returns the specified decimal digit of a 16-bit positive
    value. Adding 48 to the result simply converts the decimal digit to its
    ASCII value.

    I hope this helps.

    Best regards,

    Russell Warburton
    email: russell@w...
    website: http://www.warburtech.com
    telephone: +44 (0)7814 044 754
    Original Message
    From: "Chris Anderson" <fuel@b...>
    To: "Stamp Group" <basicstamps@yahoogroups.com>
    Sent: Saturday, December 06, 2003 10:58 AM
    Subject: [noparse][[/noparse]basicstamps] Checksum --- again...


    > Hello Stampers,
    > I am back on the checksum issue again.
    >
    > I am sending data from a stamp to a pc and receiving the data into VB6.
    > When I send the data, I send it as ascii tect, and I have the data mixed
    up
    > as bytes, words and 3 bytes together which are compiled as a 6 digit
    number
    > at the pc.
    >
    > I want to send a checksum byte to the pc at the end of the data stream,
    > which is easy, but I want to sent a checksum value which is the sum of the
    > bytes when they are sent as ascii characters using the dec formatter at
    the
    > stamp. For example, instead of sending the word value of 48332, and simplt
    > checksumming the word value or the 2 bytes, I want to checksum the value
    of
    > the bytes "4", "8", "3", "3" and "2" as they are sent. I want to be able
    to
    > checksum bytes and words.
    >
    > Is this possible? I wish to send the data as ascii because it is reliable
    > when sent thru a modem, as the data cant get mixed up with control codes
    > etc.
    >
    > Any ideas would be appreciated.
    >
    > Cheers.
    > Chris Anderson
    > Western Australia
    >
    >
    > 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/
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2003-12-07 10:23
    Russell,
    Thanks for the reply, I will have a go at it now.
    I hope I can help you one day...

    Cheers,
    Chris



    Original Message
    From: "Russell Warburton" <russell@w...>
    To: <basicstamps@yahoogroups.com>
    Sent: Saturday, December 06, 2003 7:19 PM
    Subject: Re: [noparse][[/noparse]basicstamps] Checksum --- again...


    > Hi Chris,
    >
    > Yes it is possible. You could try something like this:
    >
    > n var byte ' universal counter
    > CurrentValue var word ' current value
    > Checksum var byte ' checksum byte
    >
    > Checksum = 0
    >
    > FOR n = 0 TO 4
    > Checksum = Checksum ^ ((CurrentValue DIG n) + 48)
    > NEXT
    >
    > The DIG operator returns the specified decimal digit of a 16-bit positive
    > value. Adding 48 to the result simply converts the decimal digit to its
    > ASCII value.
    >
    > I hope this helps.
    >
    > Best regards,
    >
    > Russell Warburton
    > email: russell@w...
    > website: http://www.warburtech.com
    > telephone: +44 (0)7814 044 754
    >
    Original Message
    > From: "Chris Anderson" <fuel@b...>
    > To: "Stamp Group" <basicstamps@yahoogroups.com>
    > Sent: Saturday, December 06, 2003 10:58 AM
    > Subject: [noparse][[/noparse]basicstamps] Checksum --- again...
    >
    >
    > > Hello Stampers,
    > > I am back on the checksum issue again.
    > >
    > > I am sending data from a stamp to a pc and receiving the data into VB6.
    > > When I send the data, I send it as ascii tect, and I have the data mixed
    > up
    > > as bytes, words and 3 bytes together which are compiled as a 6 digit
    > number
    > > at the pc.
    > >
    > > I want to send a checksum byte to the pc at the end of the data stream,
    > > which is easy, but I want to sent a checksum value which is the sum of
    the
    > > bytes when they are sent as ascii characters using the dec formatter at
    > the
    > > stamp. For example, instead of sending the word value of 48332, and
    simplt
    > > checksumming the word value or the 2 bytes, I want to checksum the value
    > of
    > > the bytes "4", "8", "3", "3" and "2" as they are sent. I want to be able
    > to
    > > checksum bytes and words.
    > >
    > > Is this possible? I wish to send the data as ascii because it is
    reliable
    > > when sent thru a modem, as the data cant get mixed up with control codes
    > > etc.
    > >
    > > Any ideas would be appreciated.
    > >
    > > Cheers.
    > > Chris Anderson
    > > Western Australia
    > >
    > >
    > > 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/
    > >
    > >
    > >
    >
    >
    > 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.