Setup Example

image\head10.gif VB.NET

Dim Ret, Srlen, Cmd(31) As Integer

Dim ErrCode As Integer

Dim Srbuf() As Byte = System.Text.Encoding.ASCII.GetBytes("*IDN?")

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

Cmd(1) = 1  ' Talker address

Cmd(2) = 3  ' Listener address

Cmd(3) = 7  ' Listener address

Srlen = Srbuf.Length  ' Length of Data

Ret = GpTalkAsync(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, Srlen, Cmd[31];

DWORD ErrCode;

char Srbuf[10];

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

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

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

Cmd[3] = 7; /* Listener address */

lstrcpy((char*)Srbuf, "*IDN?"); /* Data of Send */

Srlen = lstrlen((char*)Srbuf); /* Length of Data */

Ret = GpTalkAsync(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;

string Srbuf;

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

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

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

Cmd[3] = 7; /* Listener address */

Srbuf = "*IDN?"; /* Data of Send */

Srlen = Srbuf.Length; /* Length of Data */

Ret = gpib.TalkAsync(Cmd, out Srlen, Srbuf);

/* 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 * 10)()

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

Cmd[1] = 1 # Talker address

Cmd[2] = 3 # Listener address

Cmd[3] = 7 # Listener address

Srlen.value = len("*IDN?".encode('UTF-8')) # Length of Data

ctypes.memmove(Srbuf, "*IDN?".encode('UTF-8'), Srlen.value) # Data of Send

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

# Completion check

while True:

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

    if Ret.value != 140:

        break