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

Manage controller memory, such as program and arrays More...

Functions

GCLIB_DLL_EXPORTED GReturn GCALL GProgramDownload (GCon g, GCStringIn program, GCStringIn preprocessor)
 Downloads a program to the controller's program buffer.
 
GCLIB_DLL_EXPORTED GReturn GCALL GProgramUpload (GCon g, GBufOut buffer, GSize buffer_len)
 Uploads a program from the controller's program buffer.
 
GCLIB_DLL_EXPORTED GReturn GCALL GArrayDownload (GCon g, const GCStringIn array_name, GOption first, GOption last, GCStringIn buffer)
 Downloads array data to a pre-dimensioned array in the controller's array table.
 
GCLIB_DLL_EXPORTED GReturn GCALL GArrayUpload (GCon g, const GCStringIn array_name, GOption first, GOption last, GOption delim, GBufOut buffer, GSize buffer_len)
 Uploads array data from the controller's array table.
 
GCLIB_DLL_EXPORTED GReturn GCALL GFirmwareDownload (GCon g, GCStringIn filepath)
 Upgrade firmware.
 
GCLIB_DLL_EXPORTED GReturn GCALL GProgramDownloadFile (GCon g, GCStringIn file_path, GCStringIn preprocessor)
 Program download from file.
 
GCLIB_DLL_EXPORTED GReturn GCALL GProgramUploadFile (GCon g, GCStringIn file_path)
 Program upload to file.
 
GCLIB_DLL_EXPORTED GReturn GCALL GArrayDownloadFile (GCon g, GCStringIn file_path)
 Array download from file.
 
GCLIB_DLL_EXPORTED GReturn GCALL GArrayUploadFile (GCon g, GCStringIn file_path, GCStringIn names)
 Array upload to file.
 
GCLIB_DLL_EXPORTED GReturn GCALL GSetupDownloadFile (GCon g, GCStringIn file_path, GOption options, GCStringOut info, GSize info_len)
 Download a saved controller configuration from a file.
 

Function Documentation

◆ GProgramDownload()

GCLIB_DLL_EXPORTED GReturn GCALL GProgramDownload ( GCon g,
GCStringIn program,
GCStringIn preprocessor )

Downloads a program to the controller's program buffer.

Parameters
gConnection's handle.
programNull-terminated program for download.
preprocessorOptions string for preprocessing the program before sending it to the controller. Null allows the library to use defaults for the download. See the Program Preprocessor documentation for options.
Returns
The success status or error code of the function. See gclib_errors.h for possible values.

See x_programs.cpp for an example.

◆ GProgramUpload()

GCLIB_DLL_EXPORTED GReturn GCALL GProgramUpload ( GCon g,
GBufOut buffer,
GSize buffer_len )

Uploads a program from the controller's program buffer.

Parameters
gConnection's handle.
bufferBuffer to receive the controller's program. The data will be null terminated unless function returns G_BAD_LOST_DATA due to the buffer being too small to hold the data.
buffer_lenThe length of the receive buffer.
Returns
The success status or error code of the function. See gclib_errors.h for possible values.

See x_programs.cpp for an example.

◆ GArrayDownload()

GCLIB_DLL_EXPORTED GReturn GCALL GArrayDownload ( GCon g,
const GCStringIn array_name,
GOption first,
GOption last,
GCStringIn buffer )

Downloads array data to a pre-dimensioned array in the controller's array table.

Warning
The array must already exist on the controller and be sufficient dimension to hold the desired array data, e.g. via DM.
Parameters
gConnection's handle.
array_nameNull-terminated string containing the name of the array to download. Must match the array name used in DM.
firstThe first element of the array for sub-array downloads. G_BOUNDS to omit.
lastThe last element of the array for sub-array downloads. G_BOUNDS to omit.
bufferBuffer containing the null-terminated data to be sent to the controller. The array data may be separated with carriage return, carriage return + line feed, or a comma. No spaces.
Returns
The success status or error code of the function. See gclib_errors.h for possible values.

See x_arrays.cpp for an example.

◆ GArrayUpload()

GCLIB_DLL_EXPORTED GReturn GCALL GArrayUpload ( GCon g,
const GCStringIn array_name,
GOption first,
GOption last,
GOption delim,
GBufOut buffer,
GSize buffer_len )

Uploads array data from the controller's array table.

Parameters
gConnection's handle.
array_nameNull-terminated string containing the name of the array to upload.
firstThe first element of the array for sub-array uploads. G_BOUNDS to omit.
lastThe last element of the array for sub-array uploads. G_BOUNDS to omit.
delimSets the delimeter between array elements in the returned data, G_CR specifies carriage return, G_COMMA specifies comma.
bufferBuffer to receive the uploaded data. The data will be null terminated unless function returns G_BAD_LOST_DATA due to the buffer being too small to hold the data.
buffer_lenThe length of the receive buffer.
Returns
The success status or error code of the function. See gclib_errors.h for possible values.

See x_arrays.cpp for an example.

◆ GFirmwareDownload()

GCLIB_DLL_EXPORTED GReturn GCALL GFirmwareDownload ( GCon g,
GCStringIn filepath )

Upgrade firmware.

Parameters
gConnection's handle.
filepathThe full file path to the Galil-supplied firmware hex file. See http://www.galil.com/downloads/firmware
Returns
The success status or error code of the function. See gclib_errors.h for possible values.
ec(GInfo(g, buf, sizeof(buf))); //get conntroller info
cout << buf << '\n'; //print the info
ec(GFirmwareDownload(g, "F:/1806.dmc/dmc-1806-r11a.hex"));
ec(GInfo(g, buf, sizeof(buf))); //get the info again
cout << buf << '\n';
// example output:
// GALILPCI1, DMC1846 Rev 1.1a-CM, 4232
// GALILPCI1, DMC1846 Rev 1.1a, 4232
GCLIB_DLL_EXPORTED GReturn GCALL GInfo(GCon g, GCStringOut info, GSize info_len)
Uses GUtility() and G_UTIL_INFO to provide a useful connection string.
GCLIB_DLL_EXPORTED GReturn GCALL GFirmwareDownload(GCon g, GCStringIn filepath)
Upgrade firmware.

◆ GProgramDownloadFile()

GCLIB_DLL_EXPORTED GReturn GCALL GProgramDownloadFile ( GCon g,
GCStringIn file_path,
GCStringIn preprocessor )

Program download from file.

Parameters
gConnection's handle.
file_pathNull-terminated string containing the path to the program file.
preprocessorOptions string for preprocessing the program before sending it to the controller. See GProgramDownload().
Returns
The success status or error code of the function. See gclib_errors.h for possible values.

See x_programs.cpp for an example.

◆ GProgramUploadFile()

GCLIB_DLL_EXPORTED GReturn GCALL GProgramUploadFile ( GCon g,
GCStringIn file_path )

Program upload to file.

Parameters
gConnection's handle.
file_pathNull-terminated string containing the path to the program file, file will be overwritten if it exists.
Returns
The success status or error code of the function. See gclib_errors.h for possible values.

See x_programs.cpp for an example.

◆ GArrayDownloadFile()

GCLIB_DLL_EXPORTED GReturn GCALL GArrayDownloadFile ( GCon g,
GCStringIn file_path )

Array download from file.

Downloads a csv file containing array data at file_path. If the arrays don't exist, they will be dimensioned.

Parameters
gConnection's handle.
file_pathNull-terminated string containing the path to the array file.
Returns
The success status or error code of the function. See gclib_errors.h for possible values.

See x_arrays.cpp for an example.

◆ GArrayUploadFile()

GCLIB_DLL_EXPORTED GReturn GCALL GArrayUploadFile ( GCon g,
GCStringIn file_path,
GCStringIn names )

Array upload to file.

Uploads the entire controller array table or a subset and saves the data as a csv file specified by file_path.

Parameters
gConnection's handle.
file_pathNull-terminated string containing the path to the array file, file will be overwritten if it exists.
namesNull-terminated string containing the arrays to upload, delimited with space. "" or null uploads all arrays listed in LA.
Returns
The success status or error code of the function. See gclib_errors.h for possible values.

See x_arrays.cpp for an example.

◆ GSetupDownloadFile()

GCLIB_DLL_EXPORTED GReturn GCALL GSetupDownloadFile ( GCon g,
GCStringIn file_path,
GOption options,
GCStringOut info,
GSize info_len )

Download a saved controller configuration from a file.

Parameters
gConnection's handle.
file_pathNull-terminated string containing the path to the gcb file.
optionsBit mask to determine what configuration data to download. See below for all options.
infoOptional pointer to a buffer to store the controller info. If no info is needed, specify as NULL.
info_lenLength of optional info buffer. If no info is needed, specify as NULL.
Returns
The success status or error code of the function. If the options parameter is set to 0, the return value will be a bit mask indicating which sectors in the specified GCB are not empty. Otherwise, see gclib_errors.h for possible error values.
Note
By default, GSetupDownloadFile() will stop immediately if an error is encountered downloading data. This can be overridden in the options parameter. For example, you may want to override the error if you have a backup from an 8-axis controller and want to restore the parameters for the first 4 axes to a 4-axis controller.

If both info and info_len are not NULL, the controller information will be provided regardless of the options parameter.

The options parameter is a bit mask. If options is set to 0, GSetupDownloadFile() will return a bit mask indicating which sectors in the specified GCB are not empty. The following contains a list of all currently available options:

Bit Value Function Description
1 0x0002 Restore parameters KPA, KIA, KDA, etc...
3 0x0008 Restore variables Variables are listed by the LV command
4 0x0010 Restore arrays Arrays are listed by the LA command
5 0x0020 Restore program The program is listed by the LS command
31 0x8000 Ignore errors Ignore invalid parameter errors and continue restoring data. GSetupDownloadFile() will still stop immediately if a connection issue or other fatal error is encountered

Usage example:

GCon g;
GOption opt = 0;
GSize info_len = 4096;
GReturn rc = GOpen("192.168.0.50", &g);
if (rc) return rc;
// Call GSetupDownloadFile() with options set to 0 so we can get the non-empty sector bit mask
opt = GSetupDownloadFile(g, "C:\\path\\to\\gcb\\file.gcb", 0, NULL, NULL);
info = (GCStringOut)malloc(sizeof(GCStringOut) * info_len);
// Call GSetupDownloadFile() with the bit mask returned in the previous function call
rc = GSetupDownloadFile(g, "C:\\path\\to\\gcb\\file.gcb", opt, info, info_len);
printf("Info:\n\n%s", info);
GClose(g);
free(info);
return rc;
int GReturn
Every function returns a value of type GReturn. See gclib_errors.h for possible values.
Definition gclib.h:107
int GOption
Option integer for various formatting, etc.
Definition gclib.h:110
unsigned int GSize
Size of buffers, etc.
Definition gclib.h:109
void * GCon
Connection handle. Unique for each connection in process. Assigned a non-zero value in GOpen().
Definition gclib.h:108
char * GCStringOut
C-string output from the library. Implies null-termination.
Definition gclib.h:111
GCLIB_DLL_EXPORTED GReturn GCALL GClose(GCon g)
Closes a connection to a Galil Controller.
GCLIB_DLL_EXPORTED GReturn GCALL GOpen(GCStringIn address, GCon *g)
Open a connection to a Galil Controller.
GCLIB_DLL_EXPORTED GReturn GCALL GSetupDownloadFile(GCon g, GCStringIn file_path, GOption options, GCStringOut info, GSize info_len)
Download a saved controller configuration from a file.