On Thu, 26 Jul 2012 17:55:55 +0200 Dirk Zimoch <[email protected]> wrote
about Re: stream device string/hex parsing:
Hello Dirk,
DZ> I would not use extrainput=Ignore except when absolutely necessary,
DZ> because this may hide some errors with incomplete input strings (e.g.
DZ> because of bad connections).
DZ>
DZ> Better ignore a known number of digits after your payload like
DZ> %*5c%4x%*30x
Thanks for the hint. I have changed to a pattern like this now (without
ignoring extra input):
---
# set block 0: 00000000
out ":0600020000..";
in "%*s";
# sample block 0
out ":0400000008..";
in ":0410%4x%(\$1_B00_FRONT_LEFT_I_NEG.VAL)4x%(\
$1_B00_FRONT_LEFT_U_POS.VAL)4x%(\$1_B00_FRONT_LEFT_I_POS.VAL)4x%(\
$1_B00_FRONT_RIGHT_U_NEG.VAL)4x%(\$1_B00_FRONT_RIGHT_I_NEG.VAL)4x%(\
$1_B00_FRONT_RIGHT_U_POS.VAL)4x%(\$1_B00_FRONT_RIGHT_I_POS.VAL)4x%*2c";
---
First I set digital outputs to drive an external multiplexer, then I read
8 AD channels and parse the answer into channels. This is then repeated
for other multiplexer settings (and different channel names). Appear to
work fine now.
DZ> Even better do not ignore the checksum but check it. What is the
DZ> checksum algorithm? (sum of all bytes)&0xff as 2 hex digits? See the %
DZ> <> formats.
I did not yet look into the checksumming at all. For sending commands, the
".." can be used to turn crc off, for receiving, I use the %*2c now to
ignore them.
The documentation says the packet LRC is the two's complement of the sum
over the packet's parameter and command bytes. Each binary data byte is
transmitted as two hex digits which have to be transformed into binary
form before adding them. So, looking at the available checksum algorithms,
this calls for something like %<neghexsum8>, which does not exist...