1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 <2012> 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 | Index | 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 <2012> 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: stream device string/hex parsing |
From: | Dirk Zimoch <[email protected]> |
To: | Gerrit Kühn <[email protected]> |
Cc: | [email protected], [email protected] |
Date: | Thu, 02 Aug 2012 10:06:22 +0200 |
Gerrit Kühn wrote:
On Tue, 31 Jul 2012 16:30:05 +0200 Dirk Zimoch <[email protected]> wrote about Re: stream device string/hex parsing: DZ> > The documentation says the packet LRC is the two's complement of the DZ> > sum over the packet's parameter and command bytes. Each binary data DZ> > byte is transmitted as two hex digits which have to be transformed DZ> > into binary form before adding them. So, looking at the available DZ> > checksum algorithms, this calls for something like %<neghexsum8>, DZ> > which does not exist... DZ> %0<negsum> Hm... not quite: 2012/08/01 14:33:43.162 ADC16_W Input byte 0xE7 does not match checksum 0xFC 2012/08/01 14:33:43.162 ADC16_S Input byte 0xEC does not match checksum 0x01 2012/08/01 14:33:41.162 ADC16_C Input byte 0xD7 does not match checksum 0xFB The description for <negsum> is --- One byte. The negative of the sum of all characters modulo 2^8 --- However, I do not need to sum over all characters, I need to interpret every two characters as hex value, sum over these, invert and compare the result with the hex value represented by the two checksum characters. Or am I misunderstanding something here? cu Gerrit
Hi Gerrit,I misunderstood "two hex digits which have to be transformed into binary". I understood that for example the hex digits "5a" have to be transformed to 0x35 + 0x61 = 0x91, that would be the normal <sum>. Or that they have to be transformed to 0x05 + 0x0a = 0x0f, which is <hexsum>. But it seems you need 0x5a as the result. At the moment, I don't have a checksum function for that. You can write one and add it to ChecksumConverter.cc. I usually implement the positive sums as a function. You get the negative sum with init=0xff and xorout=0xff (see checksumMap).
Good luck, Dirk