
Programming Examples
R&S FSH-K1
1157.3564.12 72
E-8
Programming Examples
The following examples are code snippets in Visual Basic (VB6).
Initialize Communication with R&S FSH
Public Function FSHInit(ByVal Port As Integer, ByVal Speed As Long,
Optional ByVal ErrorCode As String) As Boolean
Rem Initialize communication with FSH
Rem Return TRUE if device initialization was successful
Rem Return FALSE otherwise e.g. the device was not found
With MainForm.FSHCommC
.CommPort = Port
.Settings = Trim$(Str$(Speed)) + ",N,8,1"
.InBufferSize = 1000
.PortOpen = True
.InBufferCount = 0
End With
InBuffer = vbNullString
End Function
‘-------------------------------------------
Poll R&S FSH until <cr> received
Public Function PollFSH() As String
Dim CrPos As Long
With MainForm.FSHCommC
Do
InBuffer = In .Input
DoEvents
CrPos = InStr(1, InBuffer, vbCr)
Loop Until CrPos > 0
PollFSH = Left$(InBuffer, CrPos - 1)
InBuffer = Mid$(InBuffer, CrPos + 1)
End With
End Function
‘-------------------------------------------
Send CMD Command to R&S FSH
Public Function FSHCmd(ByVal Command As String) As Boolean
Dim TempError As Integer
InBuffer = vbNullString
FSHCmd = False
With MainForm.FSHCommC
.Output = "cmd" + vbCr
TempError = Val(PollFSH)
If TempError = 0 Then
.Output = C vbCr
TempError = Val(PollFSH)
If TempError = 0 Then
FSHCmd = True
Else
DebugMsg "CMD error" + Str(TempError) + " for command <" + C ">"
End If
Else
DebugMsg "CMD error" + Str(TempError) + " for command <" + C ">"
End If
End With
End Function
‘-------------------------------------------
Содержание 1157.3458.02
Страница 4: ......
Страница 5: ...R S FSH K1 Table of Contents 1157 3564 12 I 1 E 8...
Страница 6: ......