Sample Program 2
Save an image of the instrument's screen to a BMP file, then use a file transfer command
to load the file onto the PC. Save the image on the PC under the file name, "C:\test.
bmp". The conditions are the same as the GP-IB sample program in section 2.6, "Sample
Programs."
Const TIMEOUT = 1 ' time out(sec)
Private Sub cmdConnect_Click()
Dim strData As String
Dim byteData() As Byte
Dim lngDataSize As Long
'=== Connect ===
If (ConnectLan("192.168.1.100", 10001) = False) Then
MsgBox "Connection error"
Winsock1.Close
Exit Sub
End If
' === Authentication by OPEN Command ===
SendLan "open ""anonymous""" ' Send user name
lngDataSize = ReceiveLan(strData)
If (lngDataSize = -1) Then
MsgBox "Data Receive Error"
Winsock1.Close
Exit Sub
End If
SendLan " " ' Send password
lngDataSize = ReceiveLan(strData)
If (lngDataSize = -1) Then
MsgBox "Data Receive Error"
Winsock1.Close
Exit Sub
End If
If (Left(strData, 5) <> "ready") Then
MsgBox "User authentication error."
Winsock1.Close
Exit Sub
End If
'----- send command to OSA
Call SendLan("CFORM1") ' Command mode
set(AQ637X mode)
Call SendLan(":mmem:stor:grap color,bmp,""test"",int")
' Save bmp file to internal memory
Call SendLan(":mmem:data? ""test.bmp"",int") ' get file data from
OSA
lngDataSize = ReceiveBinaryLan(byteData()) ' Recieve binary block
data
'----- save data to binary file
Open "c:\test.bmp" For Binary As #1
Put #1, , byteData
Close #1
'----- Disconnect
Winsock1.Close
'Wait to disconnect complete
While (Winsock1.State <> sckClosed)
DoEvents
Wend
MsgBox "Complete"
End Sub
3.3 Sample Program