SIGLENT
SSG5000X Programming Guide 141
Next
i
' Now we will close the session to the instrument using
' viClose. This operation frees all system resources.
status = viClose(defaultRM)
Usbtmc_test = 0
End
Function
(2)
TCP/IP
access code.
Write a function
TCP_IP_Test:
Private
Function
TCP_IP_Test(
ByVal
ip
As
String
)
As
Long
Dim
outputBuffer
As
String
* VI_FIND_BUFLEN
Dim
defaultRM
As
Long
Dim
instrsesn
As
Long
Dim
status
As
Long
Dim
count
As
Long
' First we will need to open the default resource manager.
status = viOpenDefaultRM(defaultRM)
If
(status < VI_SUCCESS)
Then
resultTxt.Text = "Could not open a session to the VISA Resource Manager!"
TCP_IP_Test = status
Exit
Function
End
If
' Now we will open a session via TCP/IP device
status = viOpen(defaultRM, "TCPIP0::" + ip + "::INSTR", VI_LOAD_CONFIG, VI_NULL, instrsesn)
If
(status < VI_SUCCESS)
Then
resultTxt.Text = "An error occurred opening the session"
viClose(defaultRM)
TCP_IP_Test = status
Exit
Function
End
If
status = viWrite(instrsesn, "*IDN?", 5, count)
If
(status < VI_SUCCESS)
Then
resultTxt.Text = "Error writing to the device."
End
If
status = viRead(instrsesn, outputBuffer, VI_FIND_BUFLEN, count)
If
(status < VI_SUCCESS)
Then