newbie sending hex values over UDP socket
grante at visi.com
Tue Sep 14 21:03:43 CEST 2004
On 2004-09-14, Bill Seitz <fluxent at yahoo.com> wrote:
>> Excellent - now how about calculating a parity-check byte?
> Here's the definition of the parity byte:
> The column parity is one (1) byte. The eight bits of data in this
> byte re¬flect the odd parity of all corresponding bits in the block;
> i.e. bit 8 of the Column Parity byte is the odd parity of all bit 8's
> in the entire block.
> Column parity will be calculated by the sender as follows:
> (a) Begin with the value 255.
> (b) Exclusive OR the current value with the value of the first (or
> next) data byte beginning with the header byte. Repeat until all
> bytes up to, but not includ¬ing, the parity byte have been used.
> (c) Send the result in the column parity position.
# assume "s" is the data for which we want a parity byte
parityByte = chr(reduce(operator.__xor__,map(ord,s)))
Grant Edwards grante Yow! NOW, I'm supposed
at to SCRAMBLE two, and HOLD
visi.com th' MAYO!!
More information about the Python-list