Agilent Technologies E5071C Betriebsanweisung Seite 190

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 551
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 189
190 Chapter 12
Sample Application Programs
Controlling Using Telnet Server
The procedure corresponding to a receiving part of communication is RecvAscii (Example
12-11) and other functions. RecvAscii receives a message as ASCII format and stores it in
the dataBuf output parameter. Maximum length of the message is specified with the
maxLength input parameter. Each functional part of RecvAscii is described below.
In (1), a message (a response to a query for SCPI command) is received from the
E5061A/E5062A as a series of characters using recv function of WinSock API. If
an error occurs, the control returns to the main program with a message. recv function takes
parameters for a socket descriptor (input), a message to be received (input), message length
(input) and a flag (input).
In (2), it is determined whether each received character is LF (ASCII code: 10). When it is
LF, receiving is terminated adding NULL (ASCII code: 0) to the end of dataBuf string and
the control returns to the main program.
In (3), number of the last characters that was read out is added to the count value for
checking a number of received characters, and append the characters to the end of dataBuf
string.
Example 12-11 RecvAscii
Function RecvAscii(dataBuf As String, ByVal maxLength As Integer) As
Integer
Dim c As String * 1
Dim length As Integer
dataBuf = ""
While length < maxLength
DoEvents
count = recv(socketId, c, 1, 0) '
If count < 1 Then '
RecvAscii = RECV_ERROR '............(1)
dataBuf = Chr$(0) '
Exit Function '
End If '
If c = Chr$(10) Then '
dataBuf = dataBuf + Chr$(0) '............(2)
RecvAscii = NO_ERROR '
Exit Function '
End If '
length = length + count '............(3)
dataBuf = dataBuf + c '
Wend
RecvAscii = RECV_ERROR
End Function
Seitenansicht 189
1 2 ... 185 186 187 188 189 190 191 192 193 194 195 ... 550 551

Kommentare zu diesen Handbüchern

Vikiehs 04 Jan 2024 | 13:20:06

urenrjrjkvnm