GpibRecData


Function

Performs data receiving.

Format

Ret = GpibRecData (  Id, RecLen, RecBuf)

Parameter

Id [ VB.NET: Short ][ C, C++: short ][ C#: short ]

When using DevID:

In master mode:

Specifies the address of slave device to transmit data for talker in GpibSetAddrInfo.

Specifies address of master device and addresses of other slave devices to receive same data for listener.

(Please use this When plural devices receive data at the same time from one slave device)

In slave mode:

It is not necessary to perform GpibSetAddrInfo.

When using EqpID:

Receives data from address of slave device contained in specified EqpID.

 

RecLen [ VB.NET: Integer ][ C, C++: long * ][ C#: ref int ]

Sets the number of data to receive at most and retrieves the number of received data.

(For initial state, the number of received data does not include delimiter)

 

IN

1 to 2147483647(7FFFFFFFH)

Number of data to receive at most (bytes)

OUT

 

Number of received data (bytes)

 

RecBuf [ VB.NET: StringBuilder / Byte() ][ C, C++: char * ][ C#: out string / byte[] ]

Sets buffer for data to receive.

Return Value

Ret [ VB.NET: Integer ][ C, C++: long ][ C#: int ]

 

0

Normality completion

10001

Invalid ID was specified

10002

Driver can not be called

10952

The value of RecLen is outside the designated range

10962

Pointer to RecLen is NULL

10963

Pointer to RecBuf is NULL

10971

Information of address specification is wrong. (Only when DevID is used)

20973

When it was not a master (controller), communication accompanied by address was performed.

20990

Other asynchronous function is running

20991

Forcible termination for asynchronous function

20992

Terminates by forcible termination key

20993

Buffer for receiving is FULL

20994

TimeOut

20995

No connected device (GPIB error)

Initial Value

None

Remarks

If you want to include delimiter in RecLen, perform setting in GpibSetStatus.

When return value is 20993, the remaining data can be received by following setting.

When using DevID:

Set -1 for talker and listener in GpibSetAddrInfo, and then perform GpibRecData again.

When using EqpID:

Perform GpibRecData again.

Example

When using DevID:

Master mode:

Receives data from slave device whose address is 1, and the slave device whose address is 2 receives same data at the same time. Outputs number of received data and received data on normal completion.

C

short Talker, ListenerArray[15];

long RecLen;

char RecBuf[256];

Talker = 1;

ListenerArray[0] = 0;

ListenerArray[1] = 2;

ListenerArray[2] = -1;

Ret = GpibSetAddrInfo ( DevId, Talker, ListenerArray );

RecLen = 256;

Ret = GpibRecData ( DevId, &RecLen, RecBuf );

if ( Ret == 0 ) {

      Printf ( "%ld\n", RecLen );

      Printf ( "%s\n", RecBuf );

}

 

Slave mode:

Receives data from master device and outputs number of received data and received data on normal completion.

C

short Talker, ListenerArray[15];

long RecLen;

char RecBuf[256];

Talker = -1;

ListenerArray[0] = -1;

Ret = GpibSetAddrInfo ( DevId, Talker, ListenerArray );

RecLen = 256;

Ret = GpibRecData ( DevId, &RecLen, RecBuf );

if ( Ret == 0 ) {

      Printf ( "%ld\n", RecLen );

      Printf ( "%s\n", RecBuf );

}

 

When using EqpID:

Receives data from destination device with specified EqpID and outputs number of received data and received data on normal completion.

C

long RecLen;

char RecBuf[256];

RecLen = 256;

Ret = GpibRecData ( EqpId, &RecLen, RecBuf );

if ( Ret == 0 ) {

     Printf ( "%ld\n", RecLen );

     Printf ( "%s\n", RecBuf );

}

See Also

GpibSendData | GpibSetDelim | GpibSetTimeOut | GpibSetAddrInfo | GpibSetEscape