gclib  2.0.8
Communications API for Galil controllers and PLCs

◆ GRecord()

GCLIB_DLL_EXPORTED GReturn GCALL GRecord ( GCon  g,
union GDataRecord record,
GOption  method 
)

Provides a fresh copy of the controller's data record. Data is cast into a union, GDataRecord.

Parameters
gConnection's handle.
recordA pointer to the user's DataRecord union to hold the copy.
methodDetermines the method for acquiring the data.
  • G_QR: QR is used via command-and-response.
  • G_DR: DR is used for asynchronous acquisition.
Returns
The success status or error code of the function. See gclib_errors.h for possible values.

When using G_DR, the asynchronous data record must already be set up.

  • -s DR must be used in the GOpen() address string to subscribe to records. The driver will automatically set the second argument of DR, where applicable.
  • GRecordRate() should be issued to set DR to an appropriate interval, n. The interval must be no faster than the rate at which GRecord() is called.
  • If GRecord() is called more slowly than the data record rate, stale data will be returned until GRecord() has been called once for each record sent by the controller.

GRecord() will block until the data record is received, or the transaction times out.

Note
If this function is called with a timeout of zero and the G_DR method, a non-blocking read is performed. If a data record has been processed since the last time the function was called, this data will be returned. If there is not a processed data reecord, but there is data waiting in the socket or PCI FIFO, one read will be performed to process the waiting data. If new data is still not found after these two attempts, G_GCLIB_NON_BLOCKING_READ_EMPTY will be returned.

See x_grecord.cpp for an example. See x_nonblocking.cpp for an example of non-blocking usage.