RIGOL
Programming Guide for DS1000E, DS1000D Series
3-8
4.
Add a subfunction as follows to send commands and get returned values.
'send a setting command
Sub SendToUSB(cmd As String)
Dim retcode As Boolean
Dim send_buf(256) As Byte
Dim temp As Long
Dim cmdstr As String
cmdstr = cmd
temp = Len(cmdstr)
For i = 0 To temp - 1
tempStr = Mid(cmdstr, i + 1, 1)
send_buf(i) = Asc(tempStr)
Next i
'send a command to the oscilloscope
'the definition of interface has been mentioned in Rigolusb.h
retcode = WriteUSB(0, 1, 1, Len(cmdstr), VarPtr(send_buf(0)))
End Sub
'/acquire Returned Format from the oscilloscope
Public Function Read_USB() As String
Dim retcode As Boolean
Dim rcv_buffer(256) As Byte
Dim tmpstr As String
Dim i, size As Long
Dim rSize As Long
rSize = 100
tmpstr = ""
send a command to ask for value, after the success, a value could be
obtained from the oscilloscope.
retcode = WriteUSB(0, 2, 2, 256, 0)
'read Returned Format from the oscilloscope
retcode = ReadUSB(0, VarPtr(rSize), VarPtr(rcv_buffer(0)))