Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to transfer large files via GPIB?

Solved!
Go to solution

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!

0 Kudos
Message 1 of 9
(2,790 Views)

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. 

0 Kudos
Message 2 of 9
(2,731 Views)

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.

0 Kudos
Message 3 of 9
(2,657 Views)

What is the device that is being connected to the computer via GPIB?

0 Kudos
Message 4 of 9
(2,647 Views)

 I use Rohde & Schwarz FSEA30 and Keysight  82357B USBGPIB converter.

0 Kudos
Message 5 of 9
(2,641 Views)

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.

0 Kudos
Message 6 of 9
(2,619 Views)

What software are you calling these functions in?

 

Can you read from it in NI-MAX (i.e. using a test pannel)?

0 Kudos
Message 7 of 9
(2,615 Views)

VS 2017

0 Kudos
Message 8 of 9
(2,608 Views)
Solution
Accepted by topic author xiaochouyu

If the buffer format of "viread" is string, then the variable must be assigned an initial value.
Or set the buffer format to StringBuilder

 

0 Kudos
Message 9 of 9
(2,388 Views)