这是一个创建于 1882 天前的主题,其中的信息可能已经有所发展或是发生改变。
1. 用 recvfrom 读取到的数据和调试助手测试接收到的数据不一样,为什么呢?
2. recvfrom 读取到的数据怎么转换处理下,表示不会啊,例如下面字节处的数据怎么提取出来呢?
Byte17~Byte24 Byte25~Byte32 Byte33~Byte41 Byte42~Byte48 Byte49~…
X 正峰值点 Y 正峰值点 X 负峰值点 Y 负峰值点 曲线点
点坐标( x,y )总共占 8 个字节,横坐标和纵坐标用单精度浮点数表示。
recvfrom 读取到的数据
b'\x01\x05\xfd\xe5\x00\x00\x00\x00\x00\x00\x00\x00\xde\x01\x00\x00\x01f\xf7\xe9B:ah?\xb0\x8a\xcb?f\xf7\xe9B5\xcd\x0fA"Q\n\xbf\xa2\xc6U\xbf\xb2\xae\x9bB\xd4\t AM\xf0;\xbf\xeeZ A\xaa*<\xbf\xda\xac A^i<\xbf\xc5\xfe A\xda\xab<\xbf\xdfO!Ar\xf1<\xbf\xca\xa1!Ao9=\xbf\xb6\xf3!A\x08\x83=\xbf\xa2E"Ad\xcd=\xbf\x8d\x97"A\xab\x17>\xbf\xa7\xe8"A\x1da>\xbf\x92:#A\x10\xa9>\xbf~\x8c#A\
……
调试助手测试接收到的数据
01 05 FD E5 00 00 00 00 00 00 00 00 E1 01 00 00 01 19 F3 E9 42 DE 80 37 3F 8E 58 B1 3F 19 F3 E9 42 4E D1 0F 41 1D 4C 01 BF C6 2D 4B BF 14 AE E4 41 F0 16 20 41 BE 91 30 BF DB 68 20 41 A7 EA 30 BF C7 BA 20 41 4A ……
3 条回复 • 2019-07-26 17:48:23 +08:00
|
|
1
julykitt 2019-07-26 16:23:16 +08:00
你这个两边数据是一样的吧,只是 python debug 显示不一样。你把 python 接收到的,用二进制方式写到文件里,在用 hex 工具看看
|
|
|
2
raysmond 2019-07-26 17:43:13 +08:00
import struct
x = struct.unpack('f', bytes[0:4]) y = struct.unpack('f', bytes[4:8])
|