dllcxb 发表于 2022-11-23 09:13:01

USB串口通信,接收不完整的问题

由"飞翔的企鹅"编写的USB串口通信,在接收长数据时,会出现接收不完整的情况,只有数据的后半段,哪位大神有解决办法,跪求.实际数据:

68 06 00 10 79 05 00 49 20 ED 3A B7 AA 00 25 14 00 1C 0A 16 34 36 30 31 31 33 31 31 31 38 37 33 36 38 30 38 36 31 32 38 32 30 34 32 31 39 38 31 30 33 37 22 0C 01 20 00 68 01 16 7F 00 00 00 0A 00 00 00 B9 22 00 00 BB 22 00 00 02 00 00 00 00 00 00 00 00 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 E5 16

有时接收到数据:
00 00 00 B9 22 00 00 BB 22 00 00 02 00 00 00 00 00 00 00 00 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 E0 16

有时接收到数据:
36 38 30 38 36 31 32 38 32 30 34 32 31 39 38 31 30 33 37 22 0C 01 20 00 69 01 0B 7F 00 00 00 0A 00 00 00 B9 22 00 00 BB 22 00 00 02 00 00 00 00 00 00 00 00 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 CF 16


随风 发表于 2022-11-24 19:13:40

是少头部的四个字节吗?

dllcxb 发表于 2022-11-25 10:58:59

随风 发表于 2022-11-24 19:13
是少头部的四个字节吗?

少很多,有时是少黑色部分,有时是少黑色+紫色部分

LJX 发表于 2022-11-27 18:54:31

本帖最后由 LJX 于 2022-11-27 18:58 编辑

①每次接收信号前清除一次地址内容。②0A可是个好东西啊,你百度一下它的意思就知道了。你可以先用特定字符替换,接收到之后再反向替换回去得到原始数据。(出现问题的原因是内存地址溢出了,不信的话你发送的字节数减少到10个以内,保证发什么收到什么。加了0A又那么长不做处理这个结果很正常)

dllcxb 发表于 2022-11-28 22:13:45

LJX 发表于 2022-11-27 18:54
①每次接收信号前清除一次地址内容。②0A可是个好东西啊,你百度一下它的意思就知道了。你可以先用特定字符 ...

感谢大神指点,问题是这个数据是一个现有的设备发出来的,不知道哪个二货写的命令这么长.求教我该如何通过火山实现呢?

HS289629705 发表于 2023-7-7 18:46:27

这个 好像是 一次接收一个字节啊
页: [1]
查看完整版本: USB串口通信,接收不完整的问题