gclib  2.0.8
Communications API for Galil controllers and PLCs

◆ 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;
GCLIB_DLL_EXPORTED GReturn GCALL GClose(GCon g)
Closes 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.
Definition: arrays.c:476
GCLIB_DLL_EXPORTED GReturn GCALL GOpen(GCStringIn address, GCon *g)
Open a connection to a Galil Controller.
int GReturn
Every function returns a value of type GReturn. See gclib_errors.h for possible values.
Definition: gclib.h:93
int GOption
Option integer for various formatting, etc.
Definition: gclib.h:96
unsigned int GSize
Size of buffers, etc.
Definition: gclib.h:95
void * GCon
Connection handle. Unique for each connection in process. Assigned a non-zero value in GOpen().
Definition: gclib.h:94
char * GCStringOut
C-string output from the library. Implies null-termination.
Definition: gclib.h:97

Definition at line 476 of file arrays.c.