弱弱地问一句,大家串口通信 习惯上用什么校验和的算法?有什么优劣?
离线
CRC ?
离线
一定要用标准的CRC吗?
离线
谢谢楼上大神们,我通常按字节异或取反算了。
离线
我现在想用所有字节累加成个 32位数就行了。
离线
做通用系统,
非标就自己弄一个算法,
我也用过校验和, 8位的
那计算量不是更多?
离线
我现在想用所有字节累加成个 32位数就行了。
累加对连续的位翻转无能为力.
离线
不用怀疑, CRC是综合下来最好的了。
离线
我觉得按字节累加还好一些。
因为同时两个字节互换错误的概率不大呀。
离线
标准CRC有很多MCU有硬件支持的。
用软件速度也很快, 查表法, 哈哈哈
离线
我觉得按字节累加还好一些。
因为同时两个字节互换错误的概率不大呀。
查表后还不是得异或?
离线
确定要格式化吗 说:我觉得按字节累加还好一些。
因为同时两个字节互换错误的概率不大呀。查表后还不是得异或?
他那个异或XOR不是一两句话可以说清楚的,相信这些酒精考验的标准库....
离线
也有一种不查表一次计算8位的,
时间空间各有优势。
离线
也有一种不查表一次计算8位的,
时间空间各有优势。
不查表计算8位怎么弄?
离线
失败人士 说:也有一种不查表一次计算8位的,
时间空间各有优势。不查表计算8位怎么弄?
维基百科
https://en.wikipedia.org/wiki/Computation_of_cyclic_redundancy_checks
Computation of a cyclic redundancy check is derived from the mathematics of polynomial division, modulo two. In practice, it resembles long division of the binary message string, with a fixed number of zeroes appended, by the "generator polynomial" string except that exclusive OR operations replace subtractions. Division of this type is efficiently realised in hardware by a modified shift register,[1] and in software by a series of equivalent algorithms, starting with simple code close to the mathematics and becoming faster (and arguably more obfuscated[2]) through byte-wise parallelism and space-time tradeoffs.
Example of generating an 8-bit CRC. The generator is a Galois type shift register with xor gates placed according to powers (white numbers) of x in the generator polynomial. The message stream may be any length. After it has been shifted through the register, followed by 8 zeroes, the result in the register is the checksum.
Checking received data with checksum. The received message is shifted through the same register as used in the generator, but the received checksum is attached to it instead of zeroes. Correct data yields the all-zeroes result; a corrupted bit in either the message or checksum would give a different result, warning that an error has occurred.
Various CRC standards extend the polynomial division algorithm by specifying an initial shift register value, a final exclusive OR step and, most critically, a bit ordering (endianness). As a result, the code seen in practice deviates confusingly from "pure" division,[2] and the register may shift left or right.
离线
确定要格式化吗 说:失败人士 说:也有一种不查表一次计算8位的,
时间空间各有优势。不查表计算8位怎么弄?
维基百科
https://en.wikipedia.org/wiki/Computation_of_cyclic_redundancy_checksComputation of a cyclic redundancy check is derived from the mathematics of polynomial division, modulo two. In practice, it resembles long division of the binary message string, with a fixed number of zeroes appended, by the "generator polynomial" string except that exclusive OR operations replace subtractions. Division of this type is efficiently realised in hardware by a modified shift register,[1] and in software by a series of equivalent algorithms, starting with simple code close to the mathematics and becoming faster (and arguably more obfuscated[2]) through byte-wise parallelism and space-time tradeoffs.
Example of generating an 8-bit CRC. The generator is a Galois type shift register with xor gates placed according to powers (white numbers) of x in the generator polynomial. The message stream may be any length. After it has been shifted through the register, followed by 8 zeroes, the result in the register is the checksum.
Checking received data with checksum. The received message is shifted through the same register as used in the generator, but the received checksum is attached to it instead of zeroes. Correct data yields the all-zeroes result; a corrupted bit in either the message or checksum would give a different result, warning that an error has occurred.
Various CRC standards extend the polynomial division algorithm by specifying an initial shift register value, a final exclusive OR step and, most critically, a bit ordering (endianness). As a result, the code seen in practice deviates confusingly from "pure" division,[2] and the register may shift left or right.
good
离线
不加校验的也用过,嘿嘿
离线
crc 和校验都可以
离线
刷个分吧
离线
crc
离线
16位校验和搞定
离线
一般用的modbus协议,自带crc校验
离线
CRC
离线
推荐使用CRC
离线
简单点的累加和,或者靠谱点CRC校验。
离线
用CRC16,比简单的累加和可靠多了。
离线
顶!学习了。
离线
校验和
离线
我一般使用CRC
离线
没特殊要求就检验和,数据可能全零就再加个取反。易受干扰的每byte再加奇偶检测
离线
一般的指令通信用校验和就好了,数据包较大的上百字节的会用上CRC,大文件10KB级别的上MD5
离线
长度 + 关键字 +crc 按字节校验
离线
通信从不校验的飘过。
离线
crc16,查表法,快,代码简单
离线
看你误码率。误码率低的话可以CRC,误码率高的话可能得考虑前向纠错,比如Hsiao算法。缺点嘛,就是数据必须成块,而且块越小,ECC校验位占的带宽越高。
离线
数据量不大的情况可以参考modem通讯,包头+地址+数据(bas64转码)+crc,我们很多工业产品的串口通讯就是这样解决的。
离线