Agilent Technologies 4294A Programming Manual page 182

Precision impedance analyzer
Hide thumbs Also See for 4294A:
Table of Contents

Advertisement

Using LAN
Controlling the Agilent 4294A
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
Socket Descriptor (input), Transmit Message (input). Message Length (input) and Flag (input).
Example 12-4
SendCommand
Function SendCommand(ByVal command As String) As Integer
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.
182
MsgBox ("ERROR: socket = " + Str$(socketId))
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)
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))
OpenSocket = COMMAND_ERROR
Exit Function
End If
OpenSocket = socketId
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
'...................(2)
'
'
'
'
'...................(3)
'
'
4294A
. Parameters for the send function are
'
'
'..........(4)
'
'
'
Chapter 12

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents