
2-11
IM AQ6370C-17EN
GP-IB Interface (GP-IB1 Port)
1
2
3
4
5
6
7
8
App
Index
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".
Const BOARD_ID = 0
'GP-IB Interface card Address
Const
osa
=
1
'OSA
GP-IB
Address
Private Sub Command1_Click()
Dim intAddrList(31) As Integer
Dim intData As Integer
Dim lngDataSize As Long
Dim strData As String
Dim intI As Integer
Dim byteData() As Byte
Dim byteSaveData() As Byte
Dim lngL As Long
'----- GP-IB Interface setting
' send IFC
Call SendIFC(BOARD_ID)
' assert th REN GPIB line
intAddrList(0) = NOADDR
Call EnableRemote(BOARD_ID, intAddrList())
' GPIB time out setting
Call ibtmo(BOARD_ID, T30s)
'Time out = 30sec
'----- send command to OSA
Call SendGPIB(osa, "CFORM1")
' Command mode set(AQ637X mode)
Call SendGPIB(osa, ":mmem:stor:grap color,bmp,""test"",int")
'
Save
bmp
file
to
internal
memory
Call SendGPIB(osa, ":mmem:data? ""test.bmp"",int")
'
get
file
data
from
OSA
lngDataSize = RecieveBinaryGPIB(osa, byteData())
'
Recieve
binary
block
data
If byteData(0) <> Asc("#") Then
' check first data
MsgBox "Data format error"
Exit Sub
End If
'----- calculate data size
intData = byteData(1) - Asc("0")
strData = ""
For intI = 1 To intData
strData = s Chr(byteData(intI + 1))
Next intI
lngDataSize = Val(strData)
' data size
'----- make save data
ReDim byteSaveData(lngDataSize)
For lngL = 0 To lngDataSize - 1
byteSaveData(lngL) = byteData(lngL + i 2)
Next lngL
'----- save data to file
Open "c:\test.bmp" For Binary As #1
Put #1, , byteSaveData
Close #1
'----- Disconnect
Call EnableLocal(BOARD_ID, intAddrList())
MsgBox "Complete"
End Sub
2.6 Sample Program