Agilent Technologies 4294A Service Manual Page 182

  • Download
  • Add to my manuals
  • Print
  • Page
    / 518
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 181
182 Chapter 12
Using LAN
Controlling the Agilent 4294A
MsgBox ("ERROR: socket = " + Str$(socketId)) '...................(2)
OpenSocket = COMMAND_ERROR '
Exit Function '
End If '
'Open a connection to a server
I_SocketAddress.sin_family = AF_INET '
I_SocketAddress.sin_port = htons(PortNumber) '...................(3)
I_SocketAddress.sin_addr = ipAddress '
I_SocketAddress.sin_zero = String$(8, 0) '
x = connect(socketId, I_SocketAddress, Len(I_SocketAddress)) '
If socketId = SOCKET_ERROR Then '
MsgBox ("ERROR: connect = " + Str$(x)) '..........(4)
OpenSocket = COMMAND_ERROR '
Exit Function '
End If '
OpenSocket = socketId
End Function
Communication
The subprogram corresponding to transmit in communication is SendCommand (Example 12-4).
SendCommand uses the send function of WinSock API to transmit a message (GPIB command)
specified by command, an input parameter, to the
4294A. Parameters for the send function are
Socket Descriptor (input), Transmit Message (input). Message Length (input) and Flag (input).
Example 12-4 SendCommand
Function SendCommand(ByVal command As String) As Integer
Dim strSend As String
strSend = command + vbCrLf
count = send(socketId, ByVal strSend, Len(strSend), 0)
If count = SOCKET_ERROR Then
MsgBox ("ERROR: send = " + Str$(count))
SendCommand = COMMAND_ERROR
Exit Function
End If
SendCommand = NO_ERROR
End Function
Subprograms corresponding to receive in communication are RecvAscii (Example 12-5) and others.
RecvAscii receives a message in the ASCII format, and store it dataBuf, an output parameter. The
maximum length of a message it receives is specified through maxLength, an input parameter. Below
are described steps of RecvAscii:
In (1), the recv function of WinSock API is used to receive a message (response to Query, an GPIB
command) on a character-by-character basis. If an error occurs during this operation, the function
outputs a message and returns processing to the main program. Parameters for the recv function are
Socket Descriptor (input), Receipt Message (output), Message Length (input), and Flag (input).
In (2), whether a received character is LF (ASCII code No.: 10) is determined, and if LF, NULL
(ASCII code No.: 0) is added to the tail of the character string dataBuf, receipt is ended, and
processing returns to the main program.
In (3), the number of characters read immediately before is added to the count for checking the
number of received characters, and characters read are added to the tail of the character string
dataBuf.
Page view 181
1 2 ... 177 178 179 180 181 182 183 184 185 186 187 ... 517 518

Comments to this Manuals

No comments