大家好,我使用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个数据的方式读取所要的数据,请问该如何实现?
您的任何回答都会让我不胜感激!
已解决! 转到解答。
Is the (wanted) data always starting at byte 32?
Is the received leading (unwanted) data always the same?
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...
真不好意思,我用英语表达技术类不好。我的意思是,我可以用For循环,每次使用给VISA Read设定25个数据量,然后读出处理吗?前面的回答很感谢,有回报的!
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.
您好,对于这个问题,我还是有些问题。如图所示,在连续读的时候,通过String Subset截取字符串,是否意味着每次都会截取31个字节的字符串以后的数据?而且这31个字节是下位机在巡检的时候发送的数据,因此时间较长(30s).请问,实际用的时候是否会出现Read字节数小于31,从而截取到的字符串以00 00 00...开始?
那我究竟该如何实现只读从第32个字节开始的字符串中的数据呢?
非常感谢您的回答!
我的接收数据是这样的:31个无效的字符串,如01 01 02 02 02 03 03 03...(Hex显示)(这个过程,时间大概占30s),之后是我所要的数据,并且不会再出现01 01 02 02 02这样31个无效的字符串(这个过程,接收数据就十分快了)了。所谓的25个数据一组,是因为下位机发送的数据如果25个数据一起的话处理方便、显示直观,因为每25个数据的对应字符串表示的意义都是一样的。所以我要的是:截掉数据开头的31个字节;对于余下的数据,每次读取25个字节(已经能用For-Loop实现了)。不知我这样表达清楚了没有?
感谢您的任何回复!