hi:
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, ":MMEMATA? '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
VisaErrorHandler()
End If
Private Sub VisaErrorHandler()
Dim VisaErr As String = "0000"
Call viStatusDesc(vi, status, VisaErr)
MsgBox("Error : " & VisaErr, vbExclamation)
End Sub
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
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)
Then I try to use the terminator and change the timeout.Looks like it doesn't work.
status = viVPrintf(vi, "YST:COMM:GPIB:RTER EOI" + vbCrLf, 0)
status = viSetAttribute(vi, VI_ATTR_TMO_VALUE, 20000)
What should I do to transfer large files via GPIB?
thanks!