07-03-2018 05:57 AM
hi:
I can only read 4096 bytes through VISA.I think maybe because the buffer is up to 4096 bytes.
so how to read data beyond 4096 bytes by VISA?
thank you!
07-03-2018 08:35 AM
07-03-2018 10:25 PM
Thank you for your reply.
I know to use the LOOP. Can you tell me the specific code?
my code can't work:
Dim fanal As String = ""
Do
status = viRead(vi, strRes, 4096, retCount)
Dim x As Integer = Val(Mid(strRes, 2, 1))
Dim y As Integer = Val(Mid(strRes, 3, x))
strRes = Mid(strRes, x + 3, y)
fanal = fanal & strRes
Loop Until (retCount < 4096)
read only 16 bytes!
if use
status = viReadToFile(vi, "D:\YouName.WMF", 4096, retCount)
the result only first viReadToFile can work!
07-04-2018 07:41 AM
07-04-2018 09:14 PM
This is the code before reading ,I had disable the end character!Has no effect!
status = viVPrintf(vi, ":SYST:COMM:GPIB:RTER EOI" + vbCrLf, 0) '此命令更改分隔符。
status = viVPrintf(vi, ":HCOP:DEV:LANG WMF" + vbCrLf, 0) '设置WMF格式
status = viSetAttribute(vi, VI_ATTR_TMO_VALUE, 20000) '设置超时
status = viVPrintf(vi, ":HCOP:DEST1 'MMEM'" + vbCrLf, 0) '
status = viVPrintf(vi, ":MMEM:NAME 'C:\USER\DATA\FILE.WMF'" + vbCrLf, 0) '
status = viVPrintf(vi, ":HCOP" + vbCrLf, 0) '开始
status = viVPrintf(vi, ":MMEM:MSIS 'C’" + vbCrLf, 0) '
status = viVPrintf(vi, ":MMEM:CDIR '\USER\DATA\'" + vbCrLf, 0) '
status = viVPrintf(vi, ":MMEM:DATA? 'FILE.WMF'" + vbCrLf, 0) '
07-06-2018 11:22 AM
xiaochouyu,
Thanks for posting on our forums. There are several reasons why you may not be able to read more than 4096 bytes. I would recommend looking at the article below for more information. It may help you determine the root of the issue.
VISA Read on a Serial Device Does not Return the Requested Number of Bytes
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019KrvSAE
07-09-2018 12:46 AM
thanks
"the amount of data that it returns depends on 3 important details about your settings and your serial data: your termination character, the amount of data requested, and the timeout period."
I'm not sure then termination character is termination EOI? and can you gave me a VB.NET code?
The following section is I found from the official website of the instrument.and I am writing code based on this:
10 REM Set the termination EOI
20 IEC TERM 1
30 IEC OUT 20,"SYST:COMM:GPIB:RTER EOI"
40 REM Change the hardcopy language to WMF
50 IEC OUT 20,"HCOP:DEV:LANG WMF"
60 REM Change the hardcopy port to file
70 IEC OUT 20,"HCOP:DEST1 'MMEM'"
80 REM Set the file name
90 IEC OUT 20,"MMEM:NAME 'C:\USER\DATA\FILE.WMF'"
100 REM Make the hardcopy
110 IEC OUT 20,"HCOP;*WAI"
130 REM Set the path to hard disk c:
140 IEC OUT 20,"MMEM:MSIS 'C'"
150 REM Set the path
160 IEC OUT 20,"MMEM:CDIR '\USER\DATA\'"
170 REM Put the file in the output buffer
180 IEC OUT 20,"MMEM:DATA? 'FILE.WMF'"
190 REM The file is transferred with an header. 第一个标记是“#”
200 REM The next sign indicates how many signs will follow
210 REM now with the information how large the file is without header
220 REM So a header looks like '#43210' and will be removed by the
230 REM next steps.
240 REM Get the file out of the buffer
250 IEC IN 20,S$
270 X=VAL(MID$(S$,2,1))
280 Z=VAL(MID$(S$,3,X))
290 T$=MID$(S$,X+3,Z)
300 REM Open a file as output
310 OPENO# 1,"A:\HARDCOPY.WMF"
320 REM Save the WMF data to this file
330 PRINT# 1,T$
340 END
07-09-2018 04:33 PM
xiaochouyu,
Just to clarify a few things, are you using NI's VISA driver to interface with your instrument using .NET code in VisualBasic? Also, are you using a third-party instrument?
If my assumptions are correct, and you are using NI VISA in VisualBasic, you can find reference documentation by following the instructions in the link below:
Creating a .NET Application without Measurement Studio
I would also recommend you go over the information in the NI VISA driver help documentation here. I hope this helps.
07-09-2018 09:12 PM
thanks
In addition to the screenshot function not implemented, other functions have been implemented. Now there is only a problem with the screenshot. I can be sure that the instrument can be programmed using VB.net.