| gclib 2.0.7 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

  g | Connection's handle.
  file_path | Null-terminated string containing the path to the gcb file.
  options | Bit mask to determine what configuration data to download. See below for all options.
  info | Optional pointer to a buffer to store the controller info. If no info is needed, specify as NULL.
  info_len | Length 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;
GCStringOut info;
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;
GClose
GCLIB_DLL_EXPORTED GReturn GCALL GClose(GCon g)
Closes a connection to a Galil Controller.
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.
Definition: arrays.c:476
GOpen
GCLIB_DLL_EXPORTED GReturn GCALL GOpen(GCStringIn address, GCon *g)
Open a connection to a Galil Controller.
GReturn
int GReturn
Every function returns a value of type GReturn. See gclib_errors.h for possible values.
Definition: gclib.h:93
GOption
int GOption
Option integer for various formatting, etc.
Definition: gclib.h:96
GSize
unsigned int GSize
Size of buffers, etc.
Definition: gclib.h:95
GCon
void * GCon
Connection handle. Unique for each connection in process. Assigned a non-zero value in GOpen().
Definition: gclib.h:94
GCStringOut
char * GCStringOut
C-string output from the library. Implies null-termination.
Definition: gclib.h:97

Definition at line 476 of file arrays.c.