NI LabVIEW,CVI,数据采集等产品讨论区

取消
显示结果 
搜索替代 
您的意思是: 

RS232串口VISA读取,如何滤除接收数据中前面无效的数据?

已解决!
转到解答

        大家好,我使用VISA连续读取的数据为01 01 02 02 02 03 03 03 03 04 04 04 04 05 05 05 85 01 01 01 00 85 01 01 01 05 85 01 01 01 05| 24 01 01 01 04 24 01 01 01 04 ……(数据中'|'是我手动加上的,'|'之后的'24'是第32个数据),前面31个数据是无效的,我想略去不处理,然后再以每次读取25个数据的方式读取所要的数据,请问该如何实现?

您的任何回答都会让我不胜感激!

感谢您的任何回复!
Any reply is appreciated!
0 项奖励
1 条消息(共 18 条)
5,492 次查看

Is the (wanted) data always starting at byte 32?

Is the received leading (unwanted) data always the same? 

Message Edited by ian fung on 04-05-2010 12:07 PM
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014
依恩与LabVIEW
LVVILIB.blogspot.com
0 项奖励
2 条消息(共 18 条)
5,488 次查看
Yes,it's all the same. Exactly!
感谢您的任何回复!
Any reply is appreciated!
0 项奖励
3 条消息(共 18 条)
5,481 次查看
Then, you just need to use the String Subset with index value 31 (i.e. 32-1) to split the data...
Message Edited by ian fung on 04-05-2010 12:17 PM
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014
依恩与LabVIEW
LVVILIB.blogspot.com
0 项奖励
4 条消息(共 18 条)
5,478 次查看
Thank you very much! And can I use the For-Loop to read datas at the rate of 25 from the Port, by using the function of Property Node?
感谢您的任何回复!
Any reply is appreciated!
0 项奖励
5 条消息(共 18 条)
5,471 次查看

wkelake wrote:
Thank you very much! And can I use the For-Loop to read datas at the rate of 25 from the Port, by using the function of Property Node?
Sorry, I am afraid that I do not understand your question 😛
Why do you need the for-loop? What do you mean by "rate of 25"? What property node do you intend to use and what is it for? 
If the received data is always as 31 unwanted leading bytes and you want only 25 bytes starting from byte 32, you may do a VISA Read of 31+25=56 bytes. Then, use String subset to get the wanted bytes (index at 31), and process them for displaying needs... 

 

Message Edited by ian fung on 04-05-2010 12:36 PM
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014
依恩与LabVIEW
LVVILIB.blogspot.com
0 项奖励
6 条消息(共 18 条)
5,469 次查看

真不好意思,我用英语表达技术类不好。我的意思是,我可以用For循环,每次使用给VISA Read设定25个数据量,然后读出处理吗?前面的回答很感谢,有回报的!

感谢您的任何回复!
Any reply is appreciated!
0 项奖励
7 条消息(共 18 条)
5,459 次查看
解答
已被主题作者 wkelake 接受

wkelake wrote:

真不好意思,我用英语表达技术类不好。我的意思是,我可以用For循环,每次使用给VISA Read设定25个数据量,然后读出处理吗?前面的回答很感谢,有回报的!


If you have finite no. of times to read, for-loop is fine.
And, for VISA Read, if the return data always has 31 bytes of unwanted leading data, you should read 31+25=56 bytes of data instead. 

 

Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014
依恩与LabVIEW
LVVILIB.blogspot.com
8 条消息(共 18 条)
5,455 次查看

      您好,对于这个问题,我还是有些问题。如图所示,在连续读的时候,通过String Subset截取字符串,是否意味着每次都会截取31个字节的字符串以后的数据?而且这31个字节是下位机在巡检的时候发送的数据,因此时间较长(30s).请问,实际用的时候是否会出现Read字节数小于31,从而截取到的字符串以00 00 00...开始?
      那我究竟该如何实现只读从第32个字节开始的字符串中的数据呢?
      非常感谢您的回答!
说明.jpg

感谢您的任何回复!
Any reply is appreciated!
0 项奖励
9 条消息(共 18 条)
5,402 次查看

       我的接收数据是这样的:31个无效的字符串,如01 01 02 02 02 03 03 03...(Hex显示)(这个过程,时间大概占30s),之后是我所要的数据,并且不会再出现01 01 02 02 02这样31个无效的字符串(这个过程,接收数据就十分快了)了。所谓的25个数据一组,是因为下位机发送的数据如果25个数据一起的话处理方便、显示直观,因为每25个数据的对应字符串表示的意义都是一样的。所以我要的是:截掉数据开头的31个字节;对于余下的数据,每次读取25个字节(已经能用For-Loop实现了)。不知我这样表达清楚了没有?

       感谢您的任何回复!

感谢您的任何回复!
Any reply is appreciated!
0 项奖励
10 条消息(共 18 条)
5,401 次查看