如何确定从去codeD IR遥控器校验 [英] How to determine checksum from decoded IR remotes

查看:179
本文介绍了如何确定从去codeD IR遥控器校验的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经由一个红外遥控器控制,使用一个Arduino我去codeD的32位协议的小型3.5ch U系列直升机。除了这似乎是某种形式的校验和后3位。正如我已经成功地解码从远程渠道,在他们跟踪其对应的控制,我可以看到,在控制细微的变化产生了3位特殊的变化,那是非常可重复性和确定性。虽然我还没有找到一个共同的主题或正式重现应该校验和。我曾尝试简单的事情,就像平价或添加校验。我可以看到的校验和不断变化的特定位的影响,但是当我结合了变化,他们不只是添加到3位值。

 结构U系列//位结构从32位IR收到命令
{
   校验和无符号:3; // 0..2
   无符号Rbutton:1; // 3
   无符号Lbutton:1; // 4
   无符号的Turbo:1; // 5
   无符号频道:2; // 6,7
   无符号的修剪:6; // 8..13
   无符号的偏航:5; // 14..18
   无符号的间距:6; // 19..24
   无符号油门:7; // 25..31
};

所以,问题是的我怎么能确定该CHKSUM公式?或什么都它,作为它的一个娱乐节目。

正如它出现确定性应该能够采取校验和所记录的输出和其他27位和推导公式为它。就像PLD逻辑。而stimuls为2 ^ 27位或128M的可能性,与输出仅为2 ^ 3或8我会怀疑的&下即使小样品; 1%或更少将提供的公式。

另一种方式,就是看它作为一个加密问题,而3位校验和是一个哈希。

无论哪种方式。任何方法或指导,以确定该解决方案是大大AP preciated。

下面是样本数据


仅供参考 - 的U系列是不是西马。在西马的德code没有一个校验和。一旦我得到了U系列CHKSUM确定我会肯Shirriff的一个分支开源它们。

仅供参考

 结构体SymaR5 //位结构从32位IR收到命令
{
   无符号的修剪:8; // 0..7 0x7F的
   无符号油门:7; // 8..15 0x7F的
   无符号频道:1; // 16 0×01
   无符号的间距:8; // 17..24 0x7F的
   无符号的偏航:8; // 25..31 0x7F的
};


解决方案

平价口罩结果在七个面具始终在您的数据给奇偶校验零快速检查。 (您的位中的两个都是一样的,所以我在做面膜约规律性的假设,以消除一些竞争者)的面具是:

  0x2e5cb972
0x5cb972e5
0x72e5cb97
0x972e5cb9
0xb972e5cb
0xcb972e5c
0xe5cb972e

所有这些面具与您的任何数据值(所有32位)相与的结果是平价为零。三个可以被认为是特殊的,因为每个识别的奇偶校验位在这三个分别只发生一次(在2,9结束的那些,和c)。所以这三个掩模未经最后三个位可被用来获得每一个奇偶校验位。

面具重复这七个位: 0010111 。这个C code使用移位和异或到敷面膜和奇偶校验计算:

  P = X;
    而((X>>!= 7)= 0)
        p ^ = X;
    p值=(P ^(P>→1)^(P>&→2)^(P>&→4))及7;

其中, X P 是32位无符号类型。 X 是收到了32位。如果 P 为零完成后​​,则接收到的值还是不错的。

I have a small 3.5ch USeries helicopter controlled by an IR remote control, using an Arduino I have decoded its 32 bit protocol. Except for last 3 bits which appear to be some form of checksum. As I have successfully decoding the channels from the remote, in that they track their corresponding controls, I can see that slight changes in the controls yield specific changes in the 3 bits, that are very reproducible and deterministic. Whereas I have not yet found a common theme or formal to reproduce the supposed checksum. I have tried simple things like Parity or Added Checksum. I can see the effects of changing specific bits on the cksum but when I combine the changes they don't simply add to the 3 bit value.

struct Useries // bit structure recieved from 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 the question is "How can I determine the formula for the chksum?" or what ever it is, as to program a recreation of it.

As it appears deterministic one should be able to take the recorded output of cksum and the other 27 bits and derive a formula for it. Much like PLD logic. Whereas the stimuls being 2^27 bit or 128M possibilities, versus the output being only 2^3 or 8 I would suspect even a small sample of <1% or less would provide the formula.

Another way, Is to look at it as a crypto problem and the 3 bit cksum is a hash.

Either way. Any methods or guidance as to determine the solution is greatly appreciated.

Here is sample data


FYI - The USeries is not the Syma. The Syma's decode does not have a cksum. Once I get the USeries chksum determined I will open source them from a fork of Ken Shirriff.

Just FYI

Struct SymaR5// bit structure recieved from 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 seven masks that always give parity zero on your data. (Two of your bits are always the same, so I made an assumption about regularity in the mask to eliminate some contenders.) The masks are:

0x2e5cb972
0x5cb972e5
0x72e5cb97
0x972e5cb9
0xb972e5cb
0xcb972e5c
0xe5cb972e

Any of these masks anded with any of your data values (all 32 bits) results in parity zero. Three can be considered special, since each of your identified parity bits occurs just once respectively in those three (the ones ending in 2, 9, and c). So those three masks without the last three bits can be used to get each of the parity bits.

The mask repeats these seven bits: 0010111. This C code uses shifts and exclusive-ors to apply the mask and parity calculation:

    p = x;
    while ((x >>= 7) != 0)
        p ^= x;
    p = (p ^ (p >> 1) ^ (p >> 2) ^ (p >> 4)) & 7;

where x and p are 32-bit unsigned types. x is the 32 bits received. If p is zero when done, then the received value is good.

这篇关于如何确定从去codeD IR遥控器校验的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆