arduino - How to determine checksum from decoded IR remotes -
arduino - How to determine checksum from decoded IR remotes -
i have little 3.5ch useries helicopter controlled ir remote control, using arduino have decoded 32 bit protocol. except lastly 3 bits appear form of checksum. have decoding channels remote, in track corresponding controls, can see slight changes in controls yield specific changes in 3 bits, reproducible , deterministic. whereas have not yet found mutual theme or formal reproduce supposed checksum. have tried simple things parity or added checksum. can see effects of changing specific bits on cksum when combine changes don't add together 3 bit value.
struct useries // bit construction recieved 32 bit ir command { unsigned cksum : 3; // 0..2 unsigned rbutton : 1; // 3 unsigned lbutton : 1; // 4 unsigned turbo : 1; // 5 unsigned channel : 2; // 6,7 unsigned trim : 6; // 8..13 unsigned yaw : 5; // 14..18 unsigned pitch : 6; // 19..24 unsigned throttle : 7; // 25..31 };
so question "how can determine formula chksum?" or ever is, programme recreation of it.
as appears deterministic 1 should able take recorded output of cksum , other 27 bits , derive formula it. much pld logic. whereas stimuls beingness 2^27 bit or 128m possibilities, versus output beingness 2^3 or 8 suspect little sample of <1% or less provide formula.
another way, @ crypto problem , 3 bit cksum hash.
either way. methods or guidance determine solution appreciated.
here sample data
fyi - useries not syma. syma's decode not have cksum. 1 time useries chksum determined open source them fork of ken shirriff.
just fyi
struct symar5// bit construction recieved 32 bit ir command { unsigned trim : 8; // 0..7 0x7f unsigned throttle : 7; // 8..15 0x7f unsigned channel : 1; // 16 0x01 unsigned pitch : 8; // 17..24 0x7f unsigned yaw : 8; // 25..31 0x7f };
a quick check on parity masks results in 7 masks give parity 0 on data. (two of bits same, made assumption regularity in mask eliminate contenders.) masks are:
0x2e5cb972 0x5cb972e5 0x72e5cb97 0x972e5cb9 0xb972e5cb 0xcb972e5c 0xe5cb972e
any of these masks anded of info values (all 32 bits) results in parity zero. 3 can considered special, since each of identified parity bits occurs 1 time respectively in 3 (the ones ending in 2, 9, , c). 3 masks without lastly 3 bits can used each of parity bits.
the mask repeats these 7 bits: 0010111
. c code uses shifts , exclusive-ors apply mask , parity calculation:
p = x; while ((x >>= 7) != 0) p ^= x; p = (p ^ (p >> 1) ^ (p >> 2) ^ (p >> 4)) & 7;
where x
, p
32-bit unsigned types. x
32 bits received. if p
0 when done, received value good.
arduino checksum crc infrared
Comments
Post a Comment