08-01-2018 09:23 PM
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, ":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
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, ":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?
thanks!
Solved! Go to Solution.
08-03-2018 09:11 AM
Hey,
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?
Thanks,
-Brian J.
08-05-2018 10:23 PM
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.
08-06-2018 09:16 AM
What is the device that is being connected to the computer via GPIB?
08-06-2018 08:54 PM
I use Rohde & Schwarz FSEA30 and Keysight 82357B USBGPIB converter.
08-08-2018 04:36 AM
today,I add a code that judges the error:
If status <> VI_SUCCESS Then
VisaErrorHandler()
End If
"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.
08-08-2018 08:19 AM
What software are you calling these functions in?
Can you read from it in NI-MAX (i.e. using a test pannel)?
08-08-2018 09:19 PM
VS 2017
12-11-2018 01:14 AM
If the buffer format of "viread" is string, then the variable must be assigned an initial value.
Or set the buffer format to StringBuilder