0x7e作帧头的优势和意义何在?一直不解,谢谢。

[复制链接]
8047|9
 楼主| 汽车电子 发表于 2011-10-21 09:59 | 显示全部楼层 |阅读模式
看到有好多地方的通讯协议都是以0x7e为帧头,这样其它地方有0x7e就要作转义,要扫描所有的数据,效率这么低。
   一直搞不懂,这个有什么优势和意义 ??

   直接用2个字节或3个字节或4个字节,多字节帧头,其它数据和帧头一样的概率可认为是0了。
hotpower 发表于 2011-10-21 10:05 | 显示全部楼层
也不解
delin17 发表于 2011-10-21 10:33 | 显示全部楼层
码距大。
0x55和0xAA的码距就是8
ayb_ice 发表于 2011-10-21 13:20 | 显示全部楼层
只是习惯而已
我看很多人喜欢用0x0d,0x0a作帧头,其实就是回车与换行的ASCII码,逻辑上比较合理
来与君 发表于 2011-10-21 13:35 | 显示全部楼层
不是每种协议都经过深思熟虑后制订出来的
程序匠人 发表于 2011-10-24 21:00 | 显示全部楼层
个人比较喜欢 5 和 A 的组合
highgear 发表于 2011-10-24 21:16 | 显示全部楼层
用 7e 是有历史原因的:
http://en.wikipedia.org/wiki/High-Level_Data_Link_Control

HDLC frames can be transmitted over synchronous or asynchronous links. Those links have no mechanism to mark the beginning or end of a frame, so the beginning and end of each frame has to be identified. This is done by using a frame delimiter, or flag, which is a unique sequence of bits that is guaranteed not to be seen inside a frame. This sequence is '01111110', or, in hexadecimal notation, 0x7E. Each frame begins and ends with a frame delimiter. A frame delimiter at the end of a frame may also mark the start of the next frame. A sequence of 7 or more consecutive 1-bits within a frame will cause the frame to be aborted.

评分

参与人数 1威望 +6 收起 理由
程序匠人 + 6

查看全部评分

gogogobomb 发表于 2011-10-24 21:20 | 显示全部楼层
啊?这是什么。
NE5532 发表于 2011-10-24 21:21 | 显示全部楼层
要看应用场合,例如有线无线不同。
 楼主| 汽车电子 发表于 2011-10-24 22:06 | 显示全部楼层
个人认为:有16进制的通讯,单字帧头,无任何优势
还是喜欢用多字节,效率更高,也方便做粘包处理
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:车联网

366

主题

2058

帖子

5

粉丝
快速回复 在线客服 返回列表 返回顶部