gclib 2.1.20
Galil Communications Library
All Classes Files Functions Variables Typedefs Macros Modules Pages
Communication

Send commands More...

Functions

GCLIB_DLL_EXPORTED GCLIB_DEPRECATED GReturn GCALL GRead (GCon g, GBufOut buffer, GSize buffer_len, GSize *bytes_read)
 Performs a read on the connection.
 
GCLIB_DLL_EXPORTED GCLIB_DEPRECATED GReturn GCALL GWrite (GCon g, GBufIn buffer, GSize buffer_len)
 Performs a write on the connection.
 
GCLIB_DLL_EXPORTED GReturn GCALL GCommand (GCon g, GCStringIn command, GBufOut buffer, GSize buffer_len, GSize *bytes_returned)
 Performs a command-and-response transaction on the connection.
 
GCLIB_DLL_EXPORTED GReturn GCALL GCmd (GCon g, GCStringIn command)
 Wrapper around GCommand for use when the return value is not desired.
 
GCLIB_DLL_EXPORTED GReturn GCALL GCmdT (GCon g, GCStringIn command, GCStringOut trimmed_response, GSize response_len, GCStringOut *front)
 Wrapper around GCommand that trims the response.
 
GCLIB_DLL_EXPORTED GReturn GCALL GCmdI (GCon g, GCStringIn command, int *value)
 Wrapper around GCommand that provides the return value of a command parsed into an int.
 
GCLIB_DLL_EXPORTED GReturn GCALL GCmdD (GCon g, GCStringIn command, double *value)
 Wrapper around GCommand that provides the return value of a command parsed into a double.
 

Function Documentation

◆ GRead()

GCLIB_DLL_EXPORTED GCLIB_DEPRECATED GReturn GCALL GRead ( GCon g,
GBufOut buffer,
GSize buffer_len,
GSize * bytes_read )

Performs a read on the connection.

Deprecated
This function will be removed in a future gclib version. Contact Galil for needs not met by the other gclib functions.
Parameters
gConnection's handle.
bufferThe user's read buffer.
buffer_lenThe length of the user's read buffer.
bytes_readPointer to a GSize which will be filled with the number of bytes read upon return.
Returns
The success status or error code of the function. See gclib_errors.h for possible values.

Unsolicited messages may be returned in the read data. The high bit of each message byte will be set unless the user changes the CW setting. Interrupts and Data Records are always filtered from a read.

See x_gread_gwrite.cpp for an example.

◆ GWrite()

GCLIB_DLL_EXPORTED GCLIB_DEPRECATED GReturn GCALL GWrite ( GCon g,
GBufIn buffer,
GSize buffer_len )

Performs a write on the connection.

Deprecated
This function will be removed in a future gclib version. Contact Galil for needs not met by the other gclib functions.
Parameters
gConnection's handle.
bufferThe user's write buffer. To send a Galil command, a terminating carriage return is usually required.
buffer_lenThe length of the data in the buffer.
Returns
The success status or error code of the function. See gclib_errors.h for possible values. If G_NO_ERROR is returned, all bytes were written.
Warning
This function is deprecated and will be removed in a future gclib version. Please contact Galil for needs not covered by the other gclib functions.

See x_gread_gwrite.cpp for an example.

◆ GCommand()

GCLIB_DLL_EXPORTED GReturn GCALL GCommand ( GCon g,
GCStringIn command,
GBufOut buffer,
GSize buffer_len,
GSize * bytes_returned )

Performs a command-and-response transaction on the connection.

Parameters
gConnection's handle.
commandNull-terminated command string to send to the controller. The library will append a carriage return to the command string.
bufferBuffer for the response. Will be filled with the response from the controller. The data will be null terminated unless the function returns G_BAD_LOST_DATA due to the buffer being too small to hold the data.
buffer_lenThe size of the response buffer.
bytes_returnedThe size of the data returned from the controller. This does not include null termination. This argument may be null if the value is not desired.
Returns
The success status or error code of the function. See gclib_errors.h for possible values.

See x_gcommand.cpp for an example.

◆ GCmd()

GCLIB_DLL_EXPORTED GReturn GCALL GCmd ( GCon g,
GCStringIn command )

Wrapper around GCommand for use when the return value is not desired.

The returned data is still checked for error, e.g. ? or timeout, but is not brought out through the prototype.

Parameters
gConnection's handle.
commandNull-terminated command string to send to the controller.
Returns
The success status or error code of the function. See gclib_errors.h for possible values.

See x_gcommand.cpp for an example.

◆ GCmdT()

GCLIB_DLL_EXPORTED GReturn GCALL GCmdT ( GCon g,
GCStringIn command,
GCStringOut trimmed_response,
GSize response_len,
GCStringOut * front )

Wrapper around GCommand that trims the response.

For use when the return value is desired, is ASCII (not binary), and the response should be trimmed of trailing colon, whitespace, and optionally leading space.

Parameters
gConnection's handle.
commandNull-terminated command string to send to the controller.
trimmed_responseThe trimmed response from the controller. Trailing space is trimmed by null terminating any trailing spaces, carriage returns, or line feeds.
response_lenThe length of the trimmed_response buffer.
frontIf non-null, upon return *front will point to the first non-space character in trimmed_response. This allows trimming the front of the string without modifying the user's buffer pointer, which may be allocated on the heap.
Returns
The success status or error code of the function. See gclib_errors.h for possible values.

See x_gcommand.cpp for an example.

◆ GCmdI()

GCLIB_DLL_EXPORTED GReturn GCALL GCmdI ( GCon g,
GCStringIn command,
int * value )

Wrapper around GCommand that provides the return value of a command parsed into an int.

Use this function to get most values including TP, RP, TE, Digital I/O states, etc.

Parameters
gConnection's handle.
commandNull-terminated command string to send to the controller.
valuePointer to an int that will be filled with the return value.
Returns
The success status or error code of the function. See gclib_errors.h for possible values.

See x_gcommand.cpp for an example.

◆ GCmdD()

GCLIB_DLL_EXPORTED GReturn GCALL GCmdD ( GCon g,
GCStringIn command,
double * value )

Wrapper around GCommand that provides the return value of a command parsed into a double.

Use this function to retrieve the full Galil 4.2 range, e.g. for a variable value with fractional data, or the value of an Analog input or Output.

Parameters
gConnection's handle.
commandNull-terminated command string to send to the controller.
valuePointer to a double that will be filled with the return value.
Returns
The success status or error code of the function. See gclib_errors.h for possible values.

See x_gcommand.cpp for an example.