lowermachine/protocol/下位机和上位机通信协议.md
2022-01-16 13:44:50 +08:00

34 lines
2.2 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

| 起始 | 长度高 | 长度低 | 类型高 | 类型低 | 数据字节1 | ... | 数据字节n | 校验低 | 校验高 | 结束 |
| ---- | ------ | ------ | ------ | ------ | --------- | ---- | --------- | ------ | ------ | ---- |
| 0xAA | 0x00 | 0x03 | 's' | 't' | | | | 0xFF | 0xFF | 0xBB |
长度=数据字节数+2组成一个无符号16位数校验字节随意给值即可
类型
- 命令
- 开始命令 st长度3数据0xFF
- 停止命令sp长度3数据0xFF
- 测试命令te长度3数据0xFF
- poweron命令po长度3数据0xFF
- 设置相机触发周期对应的脉冲数sc长度4数据位十进制字符串'5''0'表示值50'5'在前,'0'在后
- 设置阀板动作对应的脉冲数sv长度4数据位十进制字符串'5''0'表示值50'5'在前,'0'在后
- 设置相机触发到阀板动作的延迟脉冲数sd长度4数据位十进制字符串'5''0'表示值100'5'在前,'0'在后
- 数据命令da 长度为3002数据要有3000个
- 数据
数据就是阀数据,其实这是一个命令,也就是数据命令'da'分到数据这一节写是因为它的参数格式和其他命令不同下表为字节排序接收时从左往右也就是数据字节1先接收到然后是数据字节2最后是数据字节6。阀1代表面向阀板最靠近右边的阀所以最左边的为阀48
| 数据字节1 | 数据字节2 | 数据字节3 | 数据字节4 | 数据字节5 | 数据字节6 |
| --------- | --------- | --------- | --------- | --------- | --------- |
| 阀48-41 | 阀40-33 | 阀32-25 | 阀24-17 | 阀16-9 | 阀8-1 |
对于各个字节其中的位是这么对应的以数据字节2为例
| 位7 | 位6 | 位5 | 位4 | 位3 | 位2 | 位1 | 位0 |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
| 阀8 | 阀7 | 阀6 | 阀5 | 阀4 | 阀3 | 阀2 | 阀1 |
需要注意的是这里的数据不是ascii编码的是直接的数据字节。上面描述字节排序的表为hostcomputer图像中的一行对应的阀动作一共500行发送完一行后接着发送下一行直到最后一行。因此一共有3000个字节的数据。