I want to transfer the picture to the PC via GIPB, but it always fails.
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)
viRead(vi, Buffer, Count, retCount)
Regardless of how large Count is (more than 4096, such as 6000), retCount is always 4096.
If I use viRead,the actual result is only 36 bytes(It should have 59936 bytes):
“#559936淄茪 ?? sW u ”
viReadToFile(vi, filename, Count, retCount)
If I use viReadToFile, the result is 4096 bytes.and retCount is always 4096 too.
Then I set the read and write buffer size. Looks like it doesn't work.
status = viSetBuf(vi, VI_READ_BUF, 60000)
status = viSetBuf(vi, VI_WRITE_BUF, 60000)
So I added a wrong judgment. Then it causes the program to enter an infinite loop.So I think it may be that the instrument does not support larger buffers.
If status <> VI_SUCCESS Then
Private Sub VisaErrorHandler()
Dim VisaErr As String = "0000"
Call viStatusDesc(vi, status, VisaErr)
MsgBox("Error : " & VisaErr, vbExclamation)
Then I tried to use the loop to read. The result is the same as once reading. Looks like the second reading didn't work
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）
Then I try to use the terminator and change the timeout.Looks like it doesn't work.
status = viVPrintf(vi, ":SYST:COMM:GPIB:RTER EOI" + vbCrLf, 0)
status = viSetAttribute(vi, VI_ATTR_TMO_VALUE, 20000)
What should I do to transfer large files via GPIB?
Solved! Go to Solution.
Have you tested this out with slightly smaller sizes to see if it is a limitation on the instrument? As in using your same protocols in different files sizes?
Thank you for your reply
I don't currently know how to write to a file. I don't know what documents are inside. So I can't try it right now.
today,I add a code that judges the error：
If status <> VI_SUCCESS Then
"ViRead" if Count value > 5000 directly causes the program to crash.
if Count value <=5000,show this error
error:VI_SUCCESS_MAX_CNT:the number of bytes read is equal to count
But,the result is still 16 bytes！
"ViReadtoFile" show this error：
Error:VI_ERROR_TMO:A timeout occurred
Whether my time is set to 20,000 seconds or 200000 seconds. Also, whether my Count value is set to 5000 or 50000.The result is always a timeout error and 4096 bytes.
I found that setting the buffer size failed.
Error:VI_ERROR_ALLOC:insufficient system resources/memory.
So the instrument's buffer is only 4096 bytes.
What software are you calling these functions in?
Can you read from it in NI-MAX (i.e. using a test pannel)?
If the buffer format of "viread" is string, then the variable must be assigned an initial value.
Or set the buffer format to StringBuilder