[Only at master]
short Count;
DWORD Pstb[2];
for(Count = 0 ; Count < 2 ; Count++){ //The number of the destination devices to poll + 1.
Pstb[Count] = 0x00; //Initializing the value.
}
Cmd[0] = 1; //The number of the destination devices to poll
Cmd[1] = GetDlgItemInt(IDC_YRADRBOX); //Specifies which device (address) to poll.
Ret = GpPoll(Cmd, Pstb); //Performs serial polling.
Notes: At first, simply explains what is the polling. Polling is that the master examines the request from the specified destination devices.
The value (status byte) polled is stored in Pstb variable.
When the return value Ret is 0 or 1, it indicates that SRQ was issued from one device. The device address and status byte can be get by using the following code.
long Adr;
long Stb;
Adr = Cmd[Pstb[0]]; //The address of device that issued SRQ
Stb = Pstb[Pstb[0]]; //Status byte
In other words, the value in the Pstb[0] indicates the location of array Cmd and Pstb in which the address and status byte of a device found SRQ out are stored.
If the return value Ret is 128, it indicates no device issued SRQ.
In addition, the status bytes are stored in elements of Pstb array even though the SRQ is not issued.
Ex.)
Cmd[1] = 2; .............Pstb[1] : Status byte of device address 2
Cmd[2] = 0; .............Pstb[2] : Status byte of device address 0
The array Cmd and array Pstb (the second argument and later) have 1 to 1 relationship.
Up to now, the polling routine is created.
In samples, the error can be get in English by using CheckRet function. This function code is written in standard module. Writing this function in the standard module makes it used for general purpose. This function can be used in other programs by "Add File". (The code of CheckRet function is written in "SubFunc.cpp".)