Docklight对分析Uart串口通讯协议非常有帮助,本文讲解一些进阶用法,特别对于通配符?, #的理解。完整工程后的效果图如下
Docklight Send/Receive Sequence List
打开新建的Docklight工程, 点击Edit -> Edit Send Sequence List | Edit Receive Sequence List
如上图,填写协议命令项的名字,数据格式,协议项完整数据.
对于可变的数据,用通配符?代替
对于可变长度,用通配符#代替,可以尽可能多填一些#
- 复制上面命令数据为(Hex格式):
AA 00 ?? 05 ?? ?? ?? ?? ?? ?? ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## 00 ??
- 以上数据为蓝牙模块通讯协议中的接收到蓝牙Name
- 数据格式依次为数据头-AA, 数据长度-00 ??, 命令字-05, 蓝牙地址-6bytes, 蓝牙名字-长度可变, 名字结尾字符-00, Checksum-??
- 对于上面蓝牙名字字段,应为是不固定长度,可以多填#
- 复制上面命令数据为(Hex格式):
通配符的一些解释
Two types of wildcards are available in Docklight(两种通配符)
Wildcard ‘?’ : Matches exactly one arbitrary character (any ASCII code between 0 and 255) - 匹配一个ASCII字符(0-255)
Wildcard ‘#’ : Matches zero or one character. This is useful for supporting variable length command arguments (e.g. a status word) in Send / Receive Sequences. See Checking for sequences with random characters or Sending commands with parameters for examples and additional information. - 匹配最多一个或者0个字符,见上面蓝牙接收名字例子