From: Jeff Waite on
What is the best way to compute a 16-bit checksum in TCL? I've tried
using the cksum() and crc::sum commands but I just receive the error
"invalid command name."

Here's my code:

set data
\x00\x4d\x41\x49\x4e\x00\x00\x00\x00\x26\x00\x04\x05\x0f\x09\x01\x06\xef\xf2\x01\xf2\xf3\x01\xf3\x54\x65\x73\x74\x69\x6e\x67\x20\x31\x32\x33\xef
LogToScreen "Checksum: cksum"
set cks [cksum($data)]
LogToScreen $cks
LogToScreen "Checksum: crc::sum"
set crcsum [crc::sum -format 0x%X $data]
LogToScreen $crcsum

FYI, I'm trying to create a checksum for a series of hex numbers. For
example:

Input:
\x00\x4d\x41\x49\x4e\x00\x00\x00\x00\x26\x00\x04\x05\x0f\x09\x01\x06\xef\xf2\x01\xf2\xf3\x01\xf3\x54\x65\x73\x74\x69\x6e\x67\x20\x31\x32\x33\xef

1. Sum up all the numbers

Sum = 0AB1

2. Convert to binary

0000 1010 1011 0001

3. Take the complement

1111 0101 0100 1110

4. Convert back to hex

F54E

5. Show low byte first and then high byte

4EF5

Checksum = 4EF5

From: Uwe Klein on
Hi,
> set cks [cksum($data)]

don't do that tcl is not C

what about:

% package require crc16
% set data
"\x00\x4d\x41\x49\x4e\x00\x00\x00\x00\x26\x00\x04\x05\x0f\
\x09\x01\x06\xef\xf2\x01\xf2\xf3\x01\xf3\x54\x65\x73\x74\
\x69\x6e\x67\x20\x31\x32\x33\xef"

% ::crc::crc16 $data
6800

G!
uwe
From: Bryan Oakley on
Jeff Waite wrote:
> What is the best way to compute a 16-bit checksum in TCL? I've tried
> using the cksum() and crc::sum commands but I just receive the error
> "invalid command name."
>
> Here's my code:
>
> set data
> \x00\x4d\x41\x49\x4e\x00\x00\x00\x00\x26\x00\x04\x05\x0f\x09\x01\x06\xef\xf2\x01\xf2\xf3\x01\xf3\x54\x65\x73\x74\x69\x6e\x67\x20\x31\x32\x33\xef
> LogToScreen "Checksum: cksum"
> set cks [cksum($data)]

Unless you've stored the name of the command in an array named cksum,
that should probably be:

set cks [crc::cksum $data]

You might need to add "package require cksum" to your code as well. It's
unfortunate that you need to do "package require cksum" but the commands
actually live in the crc namespace.

Out of curiosity, what's the point of this exercise? Is it homework?
From: eiji on
Just one hint:

download and unwrap the sdx.kit from http://www.equi4.com/sdx.html
in

sdx.vfs\lib\

you wil find a md5-checksum-tcl-tool.

I don't know what you have to do, but maybe this code could help you!?

Regards,
Sascha

From: eiji on
thats is already part of the tcllib :-)

Sorry