Products > Test Equipment
Visual Basic Code Example To Download Screen Shot from TDS3000/MSO4101/TDS5054s
<< < (3/3)
daveyk:
SUCCESS !!!!

'===================================================================================
Sub tdsSnapShot()
Dim SrnImage As Image
Dim pngFilePart As Byte
Dim strTest As String
Dim FF As Integer
Dim binData As Byte
Dim binData1 As Variant
Dim EndPNG As String * 4
Dim EndPNGLoop As Integer
Dim PNGEnd As String * 4
Dim txtTemp As String
Dim EndCounter As Integer
'
PNGEnd = "IEND"
Set ioMgr = New VisaComLib.ResourceManager
Set Scope = New VisaComLib.FormattedIO488
' Address
Set Scope.IO = ioMgr.Open(Trim(TDSAdr))
'

If Dir("C:\temp\test.png") = "test.png" Then
    Kill "C:\temp\test.png"
End If
FF = FreeFile
Open "C:\temp\test.png" For Output As #FF
'
looptimes = 0: EndPNG = "": EndPNGLoop = 0: EndCounter = 0
On Error GoTo CloseFile
'
Scope.IO.timeout = 5000
Scope.WriteString ("HARDCOPY:port gpib")
Scope.WriteString ("HARDCOPY:layout portrait")
Scope.WriteString ("HARDCOPY:format PNG")
Scope.WriteString ("HARDCOPY:compression OFF")
Scope.WriteString ("HARDCOPY:inksaver ON")
Scope.WriteString ("HARDCOPY:pallet normal")
Scope.WriteString ("WAV:STR OFF")
Scope.WriteString ("HARDCOPY START")
'
Do
    binData1 = Scope.IO.Read(1)
    Print #FF, Chr$(binData1(0));
    'Print #FF, Chr$(binData);
    EndPNGLoop = EndPNGLoop + 1
    '
    If EndPNGLoop = 5 Then
        txtTemp = Right(txtTemp, 3)
        EndPNGLoop = 4
    End If
    txtTemp = txtTemp + Chr$(binData1(0))
   
    If InStr(txtTemp, PNGEnd) > 0 Or EndCounter > 0 Then
        EndCounter = EndCounter + 1
    End If
    looptimes = looptimes + 1
    If EndCounter = 4 Then
        Exit Do
    End If
    '
Loop
'
CloseFile:
EndFile:
Close #FF
'
Scope.FlushRead
Scope.IO.Close
Set Scope.IO = Nothing
Set Scope = Nothing
On Error GoTo 0
Exit Sub
End Sub
Navigation
Message Index
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod