Serial Poll


Retrieve status byte of destination device by using serial polling function of GPIB.

Use GpibSPoll function to retrieve status byte of specified destination device by using Equipment ID.

Use GpibSPollAll function to retrieve status byte of plural destination devices by using Device ID.

 

 

Example:

Use Equipment ID

- Single (Performs serial poll to slave device specified by EqpID.)

short Stb, Srq;

        Ret = GpibSPolll ( EqpId, &Stb, &Srq );                // Retrieve status byte of destination device whose Equipment ID is specified

        if ( Ret == 0 ) {                                               // Confirms whether it is normal completion

            Printf ( "%ld\n", Stb );                                // Outputs status byte

            Printf ( "%ld\n", Srq );                                 // Outputs status for SRQ

        }

Use Device ID

- Plural (Performs serial poll to slave devices whose addresses are 1 and 2, outputs status byte and address from which SRQ is detected on normal completion.)

short AddrArray[15], StbArray[15], SrqArray[15], i, k;

 

        AddrArray[0] = 1;                                                       // Sets address to 1

        AddrArray[1] = 2;                                                       // Sets address to 2

        AddrArray[2] = -1;                                                     // Specifies [-1] as terminal (It must be input at last of array for slaves.)

        Ret = GpibSPollAll ( DevId, AddrArray, StbArray, SrqArray );  // Retrieves status bytes of destination devices whose addresses are specified

        if ( Ret == 0 ) {                                                          // Confirms whether it is normal completion

            i = 0;                                                                    // Initial variable specifying the index of array element

            k = 0;                                                                   // Initial variable specifying number of devices from which SRQ are transmitted

            while ( AddrArray[i] != -1 ) {                                    // Iterates until specified address is terminal

                if ( SrqArray [i] != 0 ) {                                        // Confirms device that outputted SRQ

                    Printf ( "%ld\n", AddrArray[i] );                       // Outputs address of destination device

                    Printf ( "%ld\n", StbArray[i] );                         // Outputs status byte

                    k++;                                                             // Counts up number of devices that outputted SRQ

                }

                i++;                                                                // Counts up the index of array element

            }

            if ( k == 0) Printf ( "No SRQ\n" );                          // Displays message when no device outputted SRQ

            }

        }

 

Practical sample:

Performs serial poll after confirming reception of SRQ.

Use Equipment ID

- Single (Performs serial poll to slave device specified by EqpID.)

short Stb, Srq;

long SRQflag;

        SRQflag = 0;                                                      // Initials flag to confirm SRQ

        do {

            Ret = GpibGetStatus ( Id, 0x12, &SRQflag);        // Confirms SRQ specification

            if ( Ret != 0 ) break;                                         // Checks return value

     } while ( SRQflag == 0 );                                       // Loops until SRQ is asserted

        if ( SRQflag == 1 ) {                                             // Confirms whether SRQ is asserted

            Ret = GpibSPoll ( EqpId, &Stb, &Srq );                // Retrieve status byte of destination device whose Equipment ID is specified

            if ( Ret == 0 ) {                                               // Confirms whether it is normal completion

                Printf ( "%ld\n", Stb );                                // Outputs status byte

                Printf ( "%ld\n", Srq );                                  // Outputs status for SRQ

            }

        }