Foxtable(狐表)用户栏目专家坐堂 → [求助]串口接收数据读取


  共有3356人关注过本帖树形打印复制链接

主题:[求助]串口接收数据读取

帅哥哟,离线,有人找我吗?
YDS
  1楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:628 积分:3594 威望:0 精华:0 注册:2011/5/21 18:05:00
[求助]串口接收数据读取  发帖心情 Post By:2020/10/28 17:50:00 [只看该作者]

16:47:55(017): 01 42 C0 AF CD 08 00 00 02 B4 01 02 01 03 42 A3 42 AA 08 00 00 01 F4 01 02 01 04 00 00 00 00 08 00 00 02 0C 01 02 01 05 00 00 00 00 08 00 00 02 10 01 02 01 06 44 7F D6 19 08 00 00 02 14 
2020/10/28: 16:47:55(049): 01 02 01 08 41 E9 59 DA 08 00 00 02 B6 01 02 01 0A 44 7E 55 D4 08 00 00 03 B6 01 02 01 09 41 3E 14 6F 08 00 00 04 C8 01 04 01 0F 00 00 FF 8A 08 00 00 05 14 01 02 01 0B 41 49 2C A0 08 
2020/10/28: 16:47:55(079): 00 00 05 16 01 02 01 07 44 80 1C 19 08 00 00 05 1C 01 02 01 0C 00 00 00 00 08 00 00 05 20 01 02 01 0D C3 2C CF AB 08 00 00 05 24 01 02 01 0E 42 C0 A7 DA 08 00 00 02 B4 01 02 01 10 42 
2020/10/28: 16:47:55(111): A3 3B 83 08 00 00 01 F4 01 02 01 11 00 00 00 00 08 00 00 02 0C 01 02 01 12 00 00 00 00 08 00 00 02 10 01 02 01 13 44 7F CD 8D 08 00 00 02 14 01 02 01 15 41 E5 97 06 08 00 00 02 B6 01 02 
2020/10/28: 16:47:55(141): 01 17 44 7E 5A 6A 08 00 00 03 B6 01 02 01 16 41 3E 1A 4A 08 00 00 04 C8 01 04 01 1C 00 00 FF EE 08 00 00 05 14 01 02 01 18 41 41 D8 60 08 00 00 
2020/10/28: 16:47:55(171): 05 16 01 02 01 14 44 80 24 4D 08 00 00 05 1C 01 02 01 19 00 00 00 00 08 00 00 05 20 01 02 01 1A C3 2D 11 4B 08 00 00 05 24 01 02 01 1B 42 C0 BB A1 08 00 00 02 B4 01 02 01 1D 42 A3 35 
2020/10/28: 16:47:55(202): 54 08 00 00 01 F4 01 02 01 1E 00 00 00 00 08 00 00 02 0C 01 02 01 1F 00 00 00 00 08 00 00 02 10 01 02 01 20 44 7F C4 71 08 00 00 02 14 01 02 01 22 41 E5 85 53 08 00 00 02 B6 01 02 01 
2020/10/28: 16:47:55(231): 24 44 7E 57 8E 08 00 00 03 B6 01 02 01 23 41 3E 19 1C 08 00 00 04 C8 01 04 01 29 00 01 00 52 08 00 00 05 14 01 02 01 25 41 41 95 30 08 00 00 05 16 01 02 01 21 44 80 1D 96 08 00 00 05 1C 
2020/10/28: 16:47:55(262): 01 02 01 26 00 00 00 00 08 00 00 05 20 01 02 01 27 C3 2C DB 95 08 00 00 05 24 01 02 01 28 42 C0 B0 E3 08 00 00 02 B4 01 02 01 2A 42 A3 3A AE 08 00 00 01 F4 01 02 01 2B 00 00 00 00 08 
2020/10/28: 16:47:55(297): 00 00 02 0C 01 02 01 2C 00 00 00 00 08 00 00 02 10 01 02 01 2D 44 7F C0 B2 08 00 00 02 14 01 02 01 2F 41 E6 A0 3A 08 00 00 02 B6 01 02 01 31 44 7E 55 C5 08 00 00 03 B6 01 02 01 30 41 
2020/10/28: 16:47:55(328): 3E 14 8C 08 00 00 04 C8 01 04 01 36 00 01 00 B6 08 00 00 05 14 01 02 01 32 41 44 24 80 08 00 00 05 16 01 02 01 2E 44 80 1B 9A 08 00 00 05 1C 01 02 01 33 00 00 00 00 08 00 00 05 20 01 02 
2020/10/28: 16:47:55(361): 01 34 C3 2C CB B4 08 00 00 05 24 01 02 01 35 42 C0 A7 0D 08 00 00 02 B4 01 02 01 37 42 A3 3E B5 08 00 00 01 F4 01 02 01 38 00 00 00 00 08 
2020/10/28: 16:47:55(393): 00 00 02 0C 01 02 01 39 00 00 00 00 08 00 00 02 10 01 02 01 3A 44 7F C8 3A 08 00 00 02 14 01 02 01 3C 41 E9 D2 B4 08 00 00 02 B6 01 02 01 3E 44 7E 5A 9D 08 00 00 03 B6 01 02 01 3D 41 
2020/10/28: 16:47:55(424): 3E 0E 17 08 00 00 04 C8 01 04 01 43 00 01 01 1A 08 00 00 05 14 01 02 01 3F 41 4A BB 10 08 00 00 05 16 01 02 01 3B 44 80 1D C0 08 00 
2020/10/28: 16:47:55(453): 00 05 1C 01 02 01 40 00 00 00 00 08 00 00 05 20 01 02 01 41 C3 2C DC E4 08 00 00 05 24 01 02 01 42 42 C0 B4 E4 08 00 
2020/10/28: 16:47:55(483): 00 02 B4 01 02 01 44 42 A3 30 B1 08 00 00 01 F4 01 02 01 45 00 00 00 00 08 00 00 02 0C 01 02 01 46 00 00 00 00 08 00 00 02 10 01 02 01 47 44 7F C6 6C 08 00 00 02 14 01 02 01 49 41 EC 
2020/10/28: 16:47:55(513): 59 5F 08 00 00 02 B6 01 02 01 4B 44 7E 5A 14 08 00 00 03 B6 01 02 01 4A 41 3E 0A 1A 08 00 00 04 C8 01 04 01 50 00 01 01 7E 08 00 00 05 14 01 02 01 4C 41 4F 88 70 08 00 00 05 
2020/10/28: 16:47:55(544): 16 01 02 01 48 44 80 20 C4 08 00 00 05 1C 01 02 01 4D 00 00 00 00 08 00 00 05 20 01 02 01 4E C3 2C F5 08 08 00 00 05 24 01 02 01 4F 42 C0 B5 FE 
2020/10/28: 16:47:55(575): 08 00 00 02 B4 01 02 01 51 42 A3 3D A4 08 00 00 01 F4 01 02 01 52 00 00 00 00 08 00 00 02 0C 01 02 01 54 00 00 00 00 08 00 00 02 10 01 02 01 55 44 7F C6 
2020/10/28: 16:47:55(606): 48 08 00 00 02 14 01 02 01 57 41 E9 2A DC 08 00 00 02 18 01 02 01 58 43 92 45 4B 08 00 00 02 24 01 02 01 59 43 92 51 EB 08 00 00 02 2C 01 05 01 69 90 10 00 01 08 00 00 02 74 01 02 01 5D 
2020/10/28: 16:47:55(637): 43 99 93 63 08 00 00 02 76 01 02 01 5E 43 99 4A FD 08 00 00 02 78 01 02 01 5F 43 99 A1 3E 08 00 00 02 7A 01 02 01 60 43 99 42 C0 08 00 00 02 80 01 02 01 53 43 92 48 A8 08 00 00 02 82 
2020/10/28: 16:47:55(668): 01 02 01 5B 43 92 47 DB 08 00 00 02 B6 01 02 01 5C 44 7E 55 92 08 00 00 03 B6 01 02 01 5A 41 3E 0D 38 08 00 00 04 C8 01 04 01 6A 00 01 01 E2 08 00 00 05 14 01 02 01 61 41 48 D2 50 08 
2020/10/28: 16:47:55(700): 00 00 05 16 01 02 01 56 44 80 1C 56 08 00 00 05 1C 01 02 01 62 00 00 00 00 08 00 00 05 20 01 02 01 63 C3 2C D1 9A 08 00 00 05 24 01 02 01 64 42 C0 AB 2A 08 00 00 05 DC 01 05 01 65 00 00 
2020/10/28: 16:47:55(731): 00 00 08 00 00 05 E4 01 05 01 66 00 00 00 00 08 00 00 05 EC 01 05 01 67 00 00 00 00 08 00 00 05 F4 01 05 01 68 00 00 00 00 08 00 00 02 B4 01 02 01 6B 42 A3 31 B8 08 00 00 01 F4 01 02 
2020/10/28: 16:47:55(764): 01 6C 00 00 00 00 08 00 00 02 0C 01 02 01 6D 00 00 00 00 08 00 00 02 10 01 02 01 6E 44 7F C3 B9 08 00 00 02 14 01 02 01 70 41 E9 DF 86 08 00 00 02 B6 01 02 01 72 44 7E 53 9D 08 00 00 
2020/10/28: 16:47:55(799): 03 B6 01 02 01 71 41 3E 0F 9F 08 00 00 04 C8 01 04 01 77 00 01 02 46 08 00 00 05 14 01 02 01 73 41 4A AC B0 08 00 00 05 16 01 02 01 6F 44 80 1C B2 08 00 00 05 1C 01 02 01 74 00 00 00 
2020/10/28: 16:47:55(829): 00 08 00 00 05 20 01 02 01 75 C3 2C D4 79 08 00 00 05 24 01 02 01 76 42 C0 A8 D2 08 00 00 02 B4 01 02 01 78 42 A3 3D 8F 08 00 00 01 F4 01 02 01 79 00 00 00 00 08 00 00 02 0C 01 02 01 7A 
2020/10/28: 16:47:55(861): 00 00 00 00 08 00 00 02 10 01 02 01 7B 44 7F C1 CC 08 00 00 02 14 01 02 01 7D 41 E3 BF 39 08 00 00 02 B6 01 02 01 7F 44 7E 51 30 08 00 00 03 B6 01 02 01 7E 41 3E 15 67 08 00 00 04 C8 
2020/10/28: 16:47:55(891): 01 04 01 84 00 01 02 AA 08 00 00 05 14 01 02 01 80 41 3E 48 D0 08 00 00 05 16 01 02 01 7C 44 80 1C A8 08 00 00 05 1C 01 02 01 81 00 00 00 00 08 00 00 05 20 01 02 01 82 C3 2C D4 29 08 
2020/10/28: 16:47:55(923): 00 00 05 24 01 02 01 83 42 C0 AE C9 08 00 00 02 B4 01 02 01 85 42 A3 37 CE 08 00 00 01 F4 01 02 01 86 00 00 00 00 08 00 00 02 0C 01 02 01 87 00 00 00 00 08 00 00 02 10 01 02 01 88 44 7F 
2020/10/28: 16:47:55(955): C7 E2 08 00 00 02 14 01 02 01 8A 41 EC F9 E5 08 00 00 02 B6 01 02 01 8C 44 7E 5B A5 08 00 00 03 B6 01 02 01 8B 41 3E 14 B8 08 00 00 04 C8 01 04 01 91 00 01 03 0E 08 00 00 05 14 01 02 
2020/10/28: 16:47:55(987): 01 8D 41 4F 99 A0 08 00 00 05 16 01 02 01 89 44 80 1C BD 08 00 00 05 1C 01 02 01 8E 00 00 00 00 08 00 00 05 20 01 02 01 8F C3 2C D4 CE 08 00 00 05 24 01 02 01 90 42 C0 A8 E1 08 00 00 


以上是S-485串口接收到数据,我需要把接收到的数据分开,每帧数据13个字节,08 00 00开头,需要怎么操作?

 回到顶部
帅哥哟,离线,有人找我吗?
YDS
  2楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:628 积分:3594 威望:0 精华:0 注册:2011/5/21 18:05:00
  发帖心情 Post By:2020/10/28 18:00:00 [只看该作者]

Dim str As String = "01 8D 41 4F 99 A0 08 00 00 05 16 01 02 01 89 44 80 1C BD 08 00 00 05 1C 01 02 01 8E 00 00 00 00 08 00 00 05 20 01 02 01 8F C3 2C D4 CE 08 00 00 05 24 01 02 01 90 42 C0 A8 E1 08 00 00"
Dim fgf As String = "08 00 00"
Dim Values() As String = str.Split(fgf)
For Index As Integer = 0 To Values.Length - 1
    Dim sv As String = Values(Index).Trim(" ")
    Output.Show(sv)
Next

我这样写出来不对

 回到顶部
帅哥哟,离线,有人找我吗?
YDS
  3楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:628 积分:3594 威望:0 精华:0 注册:2011/5/21 18:05:00
  发帖心情 Post By:2020/10/28 18:04:00 [只看该作者]

Dim str As String = "01 8D 41 4F 99 A0 08 00 00 05 16 01 02 01 89 44 80 1C BD 08 00 00 05 1C 01 02 01 8E 00 00 00 00 08 00 00 05 20 01 02 01 8F C3 2C D4 CE 08 00 00 05 24 01 02 01 90 42 C0 A8 E1 08 00 00"
str = str.Replace("08 00 00","|")
Dim Values() As String = str.Split("|")
For Index As Integer = 0 To Values.Length - 1
    Dim sv As String = Values(Index).Trim(" ")
    Output.Show(sv)
Next

修改成以上代码可以分割,但是速度比较慢,有没有什么好的办法?

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110443 积分:562081 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/10/29 8:28:00 [只看该作者]

只能这样

 回到顶部
帅哥哟,离线,有人找我吗?
YDS
  5楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:628 积分:3594 威望:0 精华:0 注册:2011/5/21 18:05:00
  发帖心情 Post By:2020/10/29 10:12:00 [只看该作者]

好的,谢谢!

 回到顶部