29 str_len = strlen(ver) + 1;
34 ver[str_len - 1] =
' ';
100 for (i = read - 1; i >= 0; i--)
102 c = trimmed_response[i];
103 if ((c ==
':') || (c ==
'\n') || (c ==
'\r'))
104 trimmed_response[i] = 0;
111 *front = trimmed_response;
115 c = trimmed_response[i++];
152 char cmd[] =
"MG_BGm";
156 GSize len = strlen(axes);
158 for (i = 0; i < len; i++)
181 return GCmd(g,
"DR 0");
193 period_arg = period_ms / dt;
197 if (strstr(buf,
"DMC18"))
198 period_arg = log(period_arg) / log(2.0);
199 else if ((strstr(buf,
"DMC40") != NULL)
200 || (strstr(buf,
"DMC500") != NULL)
201 || (strstr(buf,
"RIO") != NULL))
203 if (period_arg < 2) period_arg = 2;
205 else if ((strstr(buf,
"DMC41") != NULL) || (strstr(buf,
"DMC21") != NULL))
207 if (period_arg < 8) period_arg = 8;
209 else if ((strstr(buf,
"DMC3") != NULL))
211 if (period_arg < 4) period_arg = 4;
215 sprintf(buf,
"DR %d", (
int)period_arg);
223 char* program_buffer;
226 if (!(file = fopen(file_path,
"rb")))
229 fseek(file, 0, SEEK_END);
230 file_size = ftell(file);
236 if (!(program_buffer = malloc(file_size + 1)))
242 if (file_size != fread(program_buffer, 1, file_size, file))
245 free(program_buffer);
248 program_buffer[file_size] = 0;
258 if (file_size) free(program_buffer);
266 char* program_buffer;
269 if (!(file = fopen(file_path,
"wb")))
272 if (!(program_buffer = malloc(
MAXPROG)))
280 file_size = strlen(program_buffer);
281 if (file_size != fwrite(program_buffer, 1, file_size, file))
286 free(program_buffer);
298 error_message = G_NO_ERROR_S;
302 error_message = G_GCLIB_ERROR_S;
306 error_message = G_GCLIB_UTILITY_ERROR_S;
310 error_message = G_GCLIB_UTILITY_IP_TAKEN_S;
314 error_message = G_GCLIB_NON_BLOCKING_READ_EMPTY_S;
318 error_message = G_TIMEOUT_S;
322 error_message = G_OPEN_ERROR_S;
326 error_message = G_COMMAND_CALLED_WITH_ILLEGAL_COMMAND_S;
330 error_message = G_DATA_RECORD_ERROR_S;
334 error_message = G_UNSUPPORTED_FUNCTION_S;
338 error_message = G_BAD_ADDRESS_S;
342 error_message = G_FIRMWARE_LOAD_NOT_SUPPORTED_S;
346 error_message = G_ARRAY_NOT_DIMENSIONED_S;
350 error_message = G_ILLEGAL_DATA_IN_PROGRAM_S;
354 error_message = G_UNABLE_TO_COMPRESS_PROGRAM_TO_FIT_S;
358 error_message = G_INVALID_PREPROCESSOR_OPTIONS_S;
362 error_message = G_BAD_RESPONSE_QUESTION_MARK_S;
366 error_message = G_BAD_VALUE_RANGE_S;
370 error_message = G_BAD_FULL_MEMORY_S;
374 error_message = G_BAD_LOST_DATA_S;
378 error_message = G_BAD_FILE_S;
382 error_message = G_GCAPS_OPEN_ERROR_S;
386 error_message =
"internal error";
390 strncpy(error, error_message, error_len);
391 error[error_len - 1] = 0;
void GCALL GSleep(unsigned int timeout_ms)
Uses GUtility() and G_UTIL_SLEEP to provide a blocking sleep call which can be useful for timing-base...
#define G_SMALL_BUFFER
Most reads/writes to Galil are small. This value will easily hold most, e.g. TH, TZ, etc.
GReturn GCALL GInfo(GCon g, GCStringOut info, GSize info_len)
Uses GUtility() and G_UTIL_INFO to provide a useful connection string.
unsigned int GSize
Size of buffers, etc.
#define G_UTIL_IPREQUEST
GUtility(), get a list of hardware requesting IPs.
#define G_UTIL_GCAPS_IPREQUEST
GUtility(), get a list of hardware requesting IPs from the gcaps server.
#define G_UNABLE_TO_COMPRESS_PROGRAM_TO_FIT
Program preprocessor could not compress the program within the user's constraints.
GReturn GCALL GCmdT(GCon g, GCStringIn command, GCStringOut trimmed_response, GSize response_len, GCStringOut *front)
Wrapper around GCommand that trims the response.
#define MAXPROG
Maximum size for a program.
#define G_COMMAND_CALLED_WITH_ILLEGAL_COMMAND
GCommand() was called with an illegal command, e.g. ED, DL or QD.
#define G_DATA_RECORD_ERROR
Data record error, e.g. DR attempted on serial connection.
#define G_OPEN_ERROR
Device could not be opened. E.G. Serial port or PCI device already open.
#define G_ILLEGAL_DATA_IN_PROGRAM
Data to download not valid, e.g. \ in data.
GReturn GCALL GProgramUploadFile(GCon g, GCStringIn file_path)
Program upload to file.
#define G_BAD_RESPONSE_QUESTION_MARK
Operation received a ?, indicating controller has a TC error.
GCLIB_DLL_EXPORTED GReturn GCALL GUtility(GCon g, GOption request, GMemory memory1, GMemory memory2)
Provides read/write access to driver settings and convenience features based on the request variable...
#define G_ARRAY_NOT_DIMENSIONED
Array operation was called on an array that was not in the controller's array table, see LA command.
#define G_TIMEOUT
Operation timed out. Timeout is set by the –timeout option in GOpen() and can be overriden by GSetti...
#define POLLINGINTERVAL
Interval, in miliseconds, for polling commands, e.g. GMotionComplete().
GReturn GCALL GCmdI(GCon g, GCStringIn command, int *value)
Wrapper around GCommand that provides the return value of a command parsed into an int...
#define G_GCLIB_UTILITY_ERROR
An invalid request value was specified to GUtility.
GReturn GCALL GMotionComplete(GCon g, GCStringIn axes)
Blocking call that returns once all axes specified have completed their motion.
#define G_UTIL_SLEEP
GUtility(), specify an interval to sleep.
#define G_GCAPS_OPEN_ERROR
gcaps connection couldn't open. Server is not running or is not reachable.
#define G_UNSUPPORTED_FUNCTION
Function cannot be called on this bus. E.G. GInterrupt() on serial.
GReturn GCALL GCmd(GCon g, GCStringIn command)
Wrapper around GCommand for use when the return value is not desired.
#define G_GCLIB_ERROR
General library error. Indicates internal API caught an unexpected error. Contact Galil support if th...
#define G_UTIL_ADDRESSES
GUtility(), get a list of available connections.
GReturn GCALL GVersion(GCStringOut ver, GSize ver_len)
Uses GUtility(), G_UTIL_VERSION and G_UTIL_GCAPS_VERSION to provide the library and gcaps version num...
#define G_UTIL_INFO
GUtility(), get a connection info string.
void * GCon
Connection handle. Unique for each connection in process. Assigned a non-zero value in GOpen()...
#define G_UTIL_TIMEOUT_OVERRIDE
GUtility(), read/write access to timeout override.
#define G_UTIL_GCAPS_VERSION
GUtility(), get the version of the gcaps server.
void GCALL GError(GReturn rc, GCStringOut error, GSize error_len)
Provides a human-readable description string for return codes.
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 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 GProgramUpload(GCon g, GBufOut buffer, GSize buffer_len)
Uploads a program from the controller's program buffer.
GReturn GCALL GTimeout(GCon g, short timeout_ms)
Uses GUtility() and G_UTIL_TIMEOUT_OVERRIDE to set the library timeout.
int GReturn
Every function returns a value of type GReturn. See gclib_errors.h for possible values.
#define G_GCLIB_UTILITY_IP_TAKEN
The IP cannot be assigned because ping returned a reply.
GReturn GCALL GIpRequests(GCStringOut requests, GSize requests_len)
Uses GUtility(), G_UTIL_GCAPS_IPREQUEST or G_UTIL_IPREQUEST to provide a list of all Galil controller...
#define G_INVALID_PREPROCESSOR_OPTIONS
GProgramDownload was called with a bad preprocessor directive.
#define G_BAD_LOST_DATA
Lost data, e.g. GCommand() response buffer was too small for the controller's response.
#define G_UTIL_VERSION
GUtility(), get a library version string.
#define G_BAD_FULL_MEMORY
Not enough memory for an operation, e.g. all connections allowed for a process already taken...
#define G_BAD_VALUE_RANGE
Bad value or range, e.g. GCon g variable passed to function was bad.
const char * GCStringIn
C-string input to the library. Implies null-termination.
#define G_NO_ERROR
Return value if function succeeded.
#define G_GCLIB_NON_BLOCKING_READ_EMPTY
GMessage, GInterrupt, and GRecord can be called with a zero timeout. If there wasn't data waiting in ...
#define G_FIRMWARE_LOAD_NOT_SUPPORTED
Firmware is not supported on this bus, e.g. Ethernet for the DMC-21x3 series.
char * GCStringOut
C-string output from the library. Implies null-termination.
GReturn GCALL GAddresses(GCStringOut addresses, GSize addresses_len)
Uses GUtility(), G_UTIL_GCAPS_ADDRESSES or G_UTIL_ADDRESSES to provide a listing of all available con...
GReturn GCALL GAssign(char *ip, char *mac)
Uses GUtility(), G_UTIL_GCAPS_ASSIGN or G_UTIL_ASSIGN to assign an IP address over the Ethernet to a ...
GReturn GCALL GCmdD(GCon g, GCStringIn command, double *value)
Wrapper around GCommand that provides the return value of a command parsed into a double...
#define GCALL
Specify calling convention for Windows.
#define G_UTIL_GCAPS_ADDRESSES
GUtility(), get a list of available connections from the gcaps server.
#define G_BAD_ADDRESS
Bad address.
GReturn GCALL GProgramDownloadFile(GCon g, GCStringIn file_path, GCStringIn preprocessor)
Program download from file.
GReturn GCALL GRecordRate(GCon g, double period_ms)
Sets the asynchronous data record to a user-specified period via DR.
#define G_BAD_FILE
Bad file path, bad file contents, or bad write.
#define G_UTIL_ASSIGN
GUtility(), assign IP addresses via Boot-P reply.
#define G_UTIL_GCAPS_ASSIGN
GUtility(), assign IP addresses via Boot-P reply from the gcaps server.