Setup Example

image\head10.gif VB.NET

Dim Ret, Srlen, Cmd(31) As Integer

Dim ErrCode As Integer

Dim Srbuf(256) As Byte  ' Receive buffer

Cmd(0) = 2  ' Number of talkers and listeners (in master mode)

Cmd(1) = 3  ' Talker address

Cmd(2) = 1  ' Listener address

Srlen = 256  ' Maximum data length in bytes that can be received

Ret = GpListenAsync(Cmd, Srlen, Srbuf)

' Completion check

While True

    Ret = GpCheckAsync(0, ErrCode)

    If (Ret != 140) Then

        Exit While

    End If

End While

 

image\head10.gif C

DWORD Ret, Cmd[31], Srlen;

DWORD ErrCode;

BYTE Srbuf[256]; /* Receive buffer */

Cmd[0] = 2; /* Number of talkers and listeners (in master mode)*/

Cmd[1] = 3; /* Talker address */

Cmd[2] = 1; /* Listener address */

Srlen = 256; /* Maximum data length in bytes that can be received */

Ret = GpListenAsync(Cmd, &Srlen, Srbuf);

/* Completion check */

while (TRUE) {

Ret = GpCheckAsync(0, &ErrCode);

 if (Ret != 140) {

break;

}

}

 

image\head10.gif C#

uint Ret, Srlen;

uint[] Cmd = new uint[31];

uint ErrCode;

StringBuilder Srbuf = new StringBuilder(256);

Cmd[0] = 2; /* Number of talkers and listeners (in master mode)*/

Cmd[1] = 3; /* Talker address */

Cmd[2] = 1; /* Listener address */

Srlen = 256; /* Maximum data length in bytes that can be received */

Ret = gpib.ListenAsync(Cmd, out Srlen, Srbu);

/* Completion check */

while (TRUE) {

    Ret = gpib.CheckAsync(0, out ErrCode);

    if (Ret != 140) {

        break;

    }

}

 

image\head10.gif Python

Ret, Srlen, Cmd = ctypes.c_ulong(), ctypes.c_ulong(), (ctypes.c_ulong * 31)()

ErrCode = ctypes.c_ulong()

Srbuf = (ctypes.c_ubyte * 256)() # Receive buffer

Cmd[0] = 2 # Number of talkers and listeners (in master mode)

Cmd[1] = 3 # Talker address

Cmd[2] = 1 # Listener address

Srlen.value = 256 # Maximum data length in bytes that can be received

Ret.value = GpibPy.GpListenAsync(Cmd, ctypes.byref(Srlen), Srbuf)

# Completion check

while True:

    Ret.value = GpibPy.GpCheckAsync(0, ctypes.byref(ErrCode))

    if Ret.value != 140:

        break