gclib  1.36.3
Communications API for Galil controllers and PLCs
gclibo.c
Go to the documentation of this file.
1 
11 #include "gclibo.h"
12 
13 #ifndef _CRT_SECURE_NO_WARNINGS
14 #define _CRT_SECURE_NO_WARNINGS //use traditional C calls like strncpy()
15 #endif
16 
17 #include <stdlib.h> //atoi, atof
18 #include <string.h> //strcpy
19 #include <stdio.h> //fopen
20 #include <math.h> //log()
21 #include <time.h>
22 
23 
24 void GCALL GSleep(unsigned int timeout_ms)
25 {
26  GUtility(0, G_UTIL_SLEEP, &timeout_ms, 0);
27 }
28 
30 {
31  int str_len;
32  GReturn rc;
33  if ((rc = GUtility(0, G_UTIL_VERSION, ver, &ver_len)) != G_NO_ERROR)
34  return rc;
35 
36 #ifdef G_USE_GCAPS
37  str_len = strlen(ver) + 1;
38  ver_len -= str_len;
39  if (ver_len > 0
40  && GUtility(0, G_UTIL_GCAPS_VERSION, ver + str_len, &ver_len) == G_NO_ERROR)
41  {
42  ver[str_len - 1] = ' '; //add a delimiter
43  }
44 #endif
45 
46  return rc;
47 }
48 
50 {
51  return GUtility(g, G_UTIL_INFO, info, &info_len);
52 }
53 
54 GReturn GCALL GAddresses(GCStringOut addresses, GSize addresses_len)
55 {
56 #ifdef G_USE_GCAPS
57  GReturn rc;
58  if (G_NO_ERROR == (rc = GUtility(0, G_UTIL_GCAPS_ADDRESSES, addresses, &addresses_len)))
59  return rc;
60 #endif
61 
62  return GUtility(0, G_UTIL_ADDRESSES, addresses, &addresses_len);
63 }
64 
65 GReturn GCALL GTimeout(GCon g, short timeout_ms)
66 {
67  return GUtility(g, G_UTIL_TIMEOUT_OVERRIDE, &timeout_ms, 0);
68 }
69 
71 {
72  /*
73  * On Linux and Apple, the IP address is pinged prior to assigning.
74  * On Windows, pinging first can make the arp table stale, and the
75  * IP address unreachable for several seconds. We skip ping so that
76  * we can immediately connect.
77  */
78 
79  GReturn rc;
80  int reply = 0; //ping reply is nonzero
81 
82 #ifdef G_USE_GCAPS
83 
84 #if defined(__linux__) || defined(__APPLE__)
85  if (strlen(ip)) //can use null string to remove IP assignment from gcaps DHCP feature
86  {
87  GUtility(0, G_UTIL_GCAPS_PING, (void*)ip, &reply); //ping to see if IP address is already taken
88  if (reply)
90  }
91 #endif
92 
93  if (G_NO_ERROR == (rc = GUtility(0, G_UTIL_GCAPS_ASSIGN, (void*)ip, (void*)mac)))
94  return rc;
95 #endif
96 
97 #if defined(__linux__) || defined(__APPLE__)
98  GUtility(0, G_UTIL_PING, (void*)ip, &reply); //ping to see if IP address is already taken
99  if (reply)
101 #endif
102 
103  return GUtility(0, G_UTIL_ASSIGN, (void*)ip, (void*)mac);
104 }
105 
106 GReturn GCALL GIpRequests(GCStringOut requests, GSize requests_len)
107 {
108  GReturn rc;
109 #ifdef G_USE_GCAPS
110  rc = GUtility(0, G_UTIL_GCAPS_IPREQUEST, requests, &requests_len);
111  if (rc == G_NO_ERROR)
112  {
113  if (requests_len == 0 || strlen(requests))
114  return rc;
115  else
116  {
117  //try once more after a 5 second wait
118  GSleep(5000);
119  return GUtility(0, G_UTIL_GCAPS_IPREQUEST, requests, &requests_len);
120  }
121  }
122 #endif
123 
124  //non-gcaps version opens port listens for 5 seconds, and closes
125  return GUtility(0, G_UTIL_IPREQUEST, requests, &requests_len);
126 }
127 
129 {
130  GReturn rc;
131 #ifdef G_USE_GCAPS
132  rc = GUtility(0, G_UTIL_GCAPS_SET_SERVER, (void*)server_name, 0);
133 #else
134  rc = G_GCAPS_OPEN_ERROR;
135 #endif
136 
137 #ifdef GCLIB_LOGGING
138  if (rc != G_NO_ERROR)
139  {
140  char buf[256];
141  sprintf(buf, "GSetServer: %d", rc);
142  LogMsg(buf);
143  }
144 #endif
145 
146  return rc;
147 }
148 
150 {
151  GReturn rc = G_NO_ERROR;
152 #ifdef G_USE_GCAPS
153  rc = GUtility(0, G_UTIL_GCAPS_SERVER_STATUS, status, &status_len);
154 #else
155  rc = G_GCAPS_OPEN_ERROR;
156 #endif
157 
158 #ifdef GCLIB_LOGGING
159  if (rc != G_NO_ERROR)
160  {
161  char buf[256];
162  sprintf(buf, "GServerStatus: %d", rc);
163  LogMsg(buf);
164  }
165 #endif
166  return rc;
167 }
168 
170 {
171  GReturn rc;
172 #ifdef G_USE_GCAPS
173  rc = GUtility(0, G_UTIL_GCAPS_LIST_SERVERS, servers, &servers_len);
174 #else
175  rc = G_GCAPS_OPEN_ERROR;
176 #endif
177 
178 #ifdef GCLIB_LOGGING
179  if (rc != G_NO_ERROR)
180  {
181  char buf[256];
182  sprintf(buf, "GListServers: %d", rc);
183  LogMsg(buf);
184  }
185 #endif
186  return rc;
187 }
188 
190 {
191  GReturn rc;
192 #ifdef G_USE_GCAPS
193  //bit 0 -> publish = 1, remove = 0
194  //bit 1 -> save = 1, do not save = 0
195  unsigned short options = publish | (save << 1);
196 
197  if (G_NO_ERROR == (rc = GUtility(0, G_UTIL_GCAPS_PUBLISH_SERVER, (void*)name, &options)))
198  {
199 
200  }
201 #else
202  rc = G_GCAPS_OPEN_ERROR;
203 #endif
204 
205 #ifdef GCLIB_LOGGING
206  if (rc != G_NO_ERROR)
207  {
208  char buf[256];
209  sprintf(buf, "GPublishServer: %d", rc);
210  LogMsg(buf);
211  }
212 #endif
213 
214  return rc;
215 }
216 
217 GReturn GCALL GRemoteConnections(GCStringOut connections, GSize connections_length)
218 {
219  GReturn rc;
220 #ifdef G_USE_GCAPS
221  rc = GUtility(0, G_UTIL_GCAPS_REMOTE_CONNECTIONS, connections, &connections_length);
222 #else
223  rc = G_GCAPS_OPEN_ERROR;
224 #endif
225 
226 #ifdef GCLIB_LOGGING
227  if (rc != G_NO_ERROR)
228  {
229  char buf[256];
230  sprintf(buf, "GRemoteConnections: %d", rc);
231  LogMsg(buf);
232  }
233 #endif
234  return rc;
235 }
236 
238 {
239  char buf[G_SMALL_BUFFER]; //response usually brief, e.g. :
240  return GCommand(g, command, buf, G_SMALL_BUFFER, 0);
241 }
242 
243 GReturn GCALL GCmdT(GCon g, GCStringIn command, GCStringOut trimmed_response, GSize response_len, GCStringOut* front)
244 {
245  GSize read;
246  GReturn rc;
247  int i;
248  char c;
249  if ((rc = GCommand(g, command, trimmed_response, response_len, &read)) != G_NO_ERROR)
250  return rc;
251  //if here, the data is already null-terminated, just trim.
252  for (i = read - 1; i >= 0; i--) //read does NOT include null terminator.
253  {
254  c = trimmed_response[i];
255  if ((c == ':') || (c == '\n') || (c == '\r'))
256  trimmed_response[i] = 0; //trim it
257  else
258  break; //we hit non-trimmable data, bail out.
259  }
260 
261  if (front) //null to skip "trim" on front.
262  {
263  *front = trimmed_response;
264  i = 0;
265  do
266  {
267  c = trimmed_response[i++];
268  if (c == ' ')
269  (*front)++;
270  else
271  break;
272  } while (1); //exit will be any non-space, including null terminator
273  }
274 
275  return G_NO_ERROR;
276 }
277 
278 GReturn GCALL GCmdI(GCon g, GCStringIn command, int* value)
279 {
280  char buf[G_SMALL_BUFFER]; //response should be ~19 chars
281  GSize read;
282  GReturn rc;
283  if ((rc = GCommand(g, command, buf, G_SMALL_BUFFER, &read)) != G_NO_ERROR)
284  return rc;
285  *value = atoi(buf);
286  return G_NO_ERROR;
287 }
288 
289 GReturn GCALL GCmdD(GCon g, GCStringIn command, double* value)
290 {
291  char buf[G_SMALL_BUFFER]; //response should be ~19 chars
292  GSize read;
293  GReturn rc;
294  if ((rc = GCommand(g, command, buf, G_SMALL_BUFFER, &read)) != G_NO_ERROR)
295  return rc;
296  *value = atof(buf);
297  return G_NO_ERROR;
298 }
299 
301 {
302  char pred[] = "_BGm=0"; //predicate for polling the axis' motion status, m is a place holder replaced below.
303  GReturn rc;
304  GSize i = 0; //C, not C++
305  GSize len = strlen(axes);
306 
307  for (i = 0; i < len; i++) //iterate through all chars in axes
308  {
309  pred[3] = axes[i]; //set the axis
310  rc = GWaitForBool(g, pred, -1); //poll forever. Change this if a premature exit is desired.
311  if (rc != G_NO_ERROR)
312  return rc;
313  }//axes
314 
315  return G_NO_ERROR;
316 }
317 
318 GReturn GCALL GWaitForBool(GCon g, GCStringIn predicate, int trials)
319 {
320  char cmd[G_LINE_BUFFER];
321  char buf[G_LINE_BUFFER];
322  int rc;
323  strcpy(cmd, "MG (");
324  strcat(cmd, predicate);
325  strcat(cmd, ")"); //enclose in parenthesis
326 
327  for (; trials != 0; --trials) //negative value will poll "forever"
328  {
329  rc = GCommand(g, cmd, buf, G_SMALL_BUFFER, 0); //check the predicate
330  if (rc != G_NO_ERROR)
331  return rc;
332 
333  if (atoi(buf)) //nonzero is true, bad atoi returns 0
334  return G_NO_ERROR;
335  else
337  }
338  //if we're here, the trials ran out
339  return G_GCLIB_POLLING_FAILED;
340 }
341 
342 GReturn GCALL GRecordRate(GCon g, double period_ms)
343 {
344  char buf[G_SMALL_BUFFER];
345  double dt;
346  double period_arg;
347 
348  if (period_ms == 0) //turn off
349  return GCmd(g, "DR 0");
350 
351  if (GCmdD(g, "TM?", &dt) == G_NO_ERROR)
352  {
353  dt /= 1024.0; //ms per controller sample
354  if (!dt) dt = 1; //don't want to divide by zero below
355  }
356  else
357  {
358  dt = 0.9765625; //RIO doesn't have TM
359  }
360 
361  period_arg = period_ms / dt; //data record specified in samples between records
362 
363  if (GCmdT(g, "\x12\x16", buf, sizeof(buf), 0) == G_NO_ERROR) //Revision string, ^R^V
364  {
365  if (strstr(buf, "DMC18")) //PCI controller
366  period_arg = log(period_arg) / log(2.0); //PCI DR arg is 2^n.
367  else if ((strstr(buf, "DMC40") != NULL) //4000
368  || (strstr(buf, "DMC500") != NULL) //50000
369  || (strstr(buf, "RIO") != NULL)) // RIO
370  {
371  if (period_arg < 2) period_arg = 2; //lowest non-zero DR
372  }
373  else if ((strstr(buf, "DMC41") != NULL) || (strstr(buf, "DMC21") != NULL)) //4103, 2103
374  {
375  if (period_arg < 8) period_arg = 8; //lowest non-zero DR
376  }
377  else if ((strstr(buf, "DMC3") != NULL)) //30010, 31010
378  {
379  if (period_arg < 4) period_arg = 4; //lowest non-zero DR
380  }
381  }
382 
383  sprintf(buf, "DR %d", (int)period_arg);
384  return GCmd(g, buf);
385 }
386 
388 {
389  FILE *file;
390  long file_size;
391  char* program_buffer;
392  GReturn rc = G_NO_ERROR;
393 
394  if (!(file = fopen(file_path, "rb"))) //open file for reading, binary mode
395  return G_BAD_FILE;
396 
397  fseek(file, 0, SEEK_END); //find end of file
398  file_size = ftell(file); //add one to null terminate below
399  rewind(file);
400 
401  if (file_size) //don't malloc 0.
402  {
403 
404  if (!(program_buffer = malloc(file_size + 1))) //allocate memory for the data, +1 for null termination below
405  {
406  fclose(file);
407  return G_BAD_FULL_MEMORY;
408  }
409 
410  if (file_size != fread(program_buffer, 1, file_size, file))
411  {
412  fclose(file);
413  free(program_buffer); //free memory
414  return G_BAD_FILE;
415  }
416  program_buffer[file_size] = 0; //null terminate, malloc was one byte larger for this
417  }
418  else
419  {
420  program_buffer = ""; //nullstring
421  }
422 
423  fclose(file); //done with file, close it
424 
425  rc = GProgramDownload(g, program_buffer, preprocessor); //call the gclib downloader
426  if (file_size) free(program_buffer); //free memory
427  return rc;
428 }
429 
431 {
432  FILE *file;
433  GReturn rc = G_NO_ERROR;
434  char* program_buffer;
435  long file_size;
436 
437  if (!(file = fopen(file_path, "wb"))) //open file for writing, binary mode
438  return G_BAD_FILE;
439 
440  if (!(program_buffer = malloc(MAXPROG))) //allocate memory for the data
441  {
442  fclose(file);
443  return G_BAD_FULL_MEMORY;
444  }
445 
446  if ((rc = GProgramUpload(g, program_buffer, MAXPROG)) == G_NO_ERROR)
447  {
448  file_size = strlen(program_buffer);
449  if (file_size != fwrite(program_buffer, 1, file_size, file))
450  rc = G_BAD_FILE;
451  }
452 
453  fclose(file);
454  free(program_buffer);
455  return rc;
456 }
457 
458 
460 {
461  char* error_message;
462 
463  switch (rc)
464  {
465  case G_NO_ERROR:
466  error_message = G_NO_ERROR_S;
467  break;
468 
469  case G_GCLIB_ERROR:
470  error_message = G_GCLIB_ERROR_S;
471  break;
472 
474  error_message = G_GCLIB_UTILITY_ERROR_S;
475  break;
476 
478  error_message = G_GCLIB_UTILITY_IP_TAKEN_S;
479  break;
480 
482  error_message = G_GCLIB_NON_BLOCKING_READ_EMPTY_S;
483  break;
484 
485  case G_TIMEOUT:
486  error_message = G_TIMEOUT_S;
487  break;
488 
489  case G_OPEN_ERROR:
490  error_message = G_OPEN_ERROR_S;
491  break;
492 
493  case G_READ_ERROR:
494  error_message = G_READ_ERROR_S;
495  break;
496 
497  case G_WRITE_ERROR:
498  error_message = G_WRITE_ERROR_S;
499  break;
500 
502  error_message = G_COMMAND_CALLED_WITH_ILLEGAL_COMMAND_S;
503  break;
504 
505  case G_DATA_RECORD_ERROR:
506  error_message = G_DATA_RECORD_ERROR_S;
507  break;
508 
510  error_message = G_UNSUPPORTED_FUNCTION_S;
511  break;
512 
513  case G_BAD_ADDRESS:
514  error_message = G_BAD_ADDRESS_S;
515  break;
516 
517  case G_BAD_FIRMWARE_LOAD:
518  error_message = G_BAD_FIRMWARE_LOAD_S;
519  break;
520 
522  error_message = G_FIRMWARE_LOAD_NOT_SUPPORTED_S;
523  break;
524 
526  error_message = G_ARRAY_NOT_DIMENSIONED_S;
527  break;
528 
530  error_message = G_CONNECTION_NOT_ESTABLISHED_S;
531  break;
532 
534  error_message = G_ILLEGAL_DATA_IN_PROGRAM_S;
535  break;
536 
538  error_message = G_UNABLE_TO_COMPRESS_PROGRAM_TO_FIT_S;
539  break;
540 
542  error_message = G_INVALID_PREPROCESSOR_OPTIONS_S;
543  break;
544 
546  error_message = G_BAD_RESPONSE_QUESTION_MARK_S;
547  break;
548 
549  case G_BAD_VALUE_RANGE:
550  error_message = G_BAD_VALUE_RANGE_S;
551  break;
552 
553  case G_BAD_FULL_MEMORY:
554  error_message = G_BAD_FULL_MEMORY_S;
555  break;
556 
557  case G_BAD_LOST_DATA:
558  error_message = G_BAD_LOST_DATA_S;
559  break;
560 
561  case G_BAD_FILE:
562  error_message = G_BAD_FILE_S;
563  break;
564 
565  case G_GCAPS_OPEN_ERROR:
566  error_message = G_GCAPS_OPEN_ERROR_S;
567  break;
568 
570  error_message = G_GCAPS_SUBSCRIPTION_ERROR_S;
571  break;
572 
573  default:
574  error_message = "internal error";
575  break;
576  }
577 
578  strncpy(error, error_message, error_len);
579  error[error_len - 1] = 0; //ensure null termination
580 }
581 
582 #ifdef GCLIB_LOGGING
583 void LogMsg(const char* msg)
584 {
585  time_t rawtime;
586  struct tm * timeinfo;
587 
588  time(&rawtime);
589  timeinfo = localtime(&rawtime);
590  char* time_string = asctime(timeinfo);
591 
592 #ifdef _WIN32
593  const char* filename = "C:/ProgramData/Galil/gcaps/gclib_mdns_log.txt";
594 #else
595  const char* filename = "/var/tmp/gclib_mdns_log.txt";
596 #endif // _WIN32
597 
598  FILE *logfile;
599  logfile = fopen(filename, "a");
600  fprintf(logfile, "%s | %s", msg, time_string);
601  fclose(logfile);
602 }
603 #endif
604 
GCLIB_DLL_EXPORTED GReturn GCALL GMotionComplete(GCon g, GCStringIn axes)
Blocking call that returns once all axes specified have completed their motion.
Definition: gclibo.c:300
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.
GCLIB_DLL_EXPORTED GReturn GCALL GPublishServer(GCStringIn name, GOption publish, GOption save)
Uses GUtility(), G_UTIL_GCAPS_PUBLISH_SERVER to publish local gcaps server to the local network.
Definition: gclibo.c:189
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.
Definition: gclibo.c:243
GCLIB_DLL_EXPORTED GReturn GCALL GAssign(GCStringIn ip, GCStringIn mac)
Uses GUtility(), G_UTIL_GCAPS_ASSIGN or G_UTIL_ASSIGN to assign an IP address over the Ethernet to a ...
Definition: gclibo.c:70
GCLIB_DLL_EXPORTED GReturn GCALL GProgramDownloadFile(GCon g, GCStringIn file_path, GCStringIn preprocessor)
Program download from file.
Definition: gclibo.c:387
GCLIB_DLL_EXPORTED 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...
Definition: gclibo.c:106
GCLIB_DLL_EXPORTED 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...
Definition: gclibo.c:24
GCLIB_DLL_EXPORTED GReturn GCALL GTimeout(GCon g, short timeout_ms)
Uses GUtility() and G_UTIL_TIMEOUT_OVERRIDE to set the library timeout.
Definition: gclibo.c:65
GCLIB_DLL_EXPORTED GReturn GCALL GListServers(GCStringOut servers, GSize servers_len)
Uses GUtility(), G_UTIL_GCAPS_LIST_SERVERS to provide a list of all available gcaps services on the l...
Definition: gclibo.c:169
GCLIB_DLL_EXPORTED 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...
Definition: gclibo.c:29
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 GRemoteConnections(GCStringOut connections, GSize connections_length)
Uses GUtility(), G_UTIL_GCAPS_REMOTE_CONNECTIONS to get a list of remote addresses connected to the l...
Definition: gclibo.c:217
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 void GCALL GError(GReturn rc, GCStringOut error, GSize error_len)
Provides a human-readable description string for return codes.
Definition: gclibo.c:459
GCLIB_DLL_EXPORTED GReturn GCALL GProgramUploadFile(GCon g, GCStringIn file_path)
Program upload to file.
Definition: gclibo.c:430
GCLIB_DLL_EXPORTED GReturn GCALL GRecordRate(GCon g, double period_ms)
Sets the asynchronous data record to a user-specified period via DR.
Definition: gclibo.c:342
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.
Definition: gclibo.c:278
GCLIB_DLL_EXPORTED GReturn GCALL GServerStatus(GCStringOut status, GSize status_len)
Uses GUtility(), G_UTIL_GCAPS_SERVER_STATUS to get information on the local server name and if it is ...
Definition: gclibo.c:149
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 GWaitForBool(GCon g, GCStringIn predicate, int trials)
Blocking call that returns when the controller evaluates the predicate as true.
Definition: gclibo.c:318
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.
Definition: gclibo.c:49
GCLIB_DLL_EXPORTED GReturn GCALL GSetServer(GCStringIn server_name)
Uses GUtility(), G_UTIL_GCAPS_SET_SERVER to set the new active server.
Definition: gclibo.c:128
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.
Definition: gclibo.c:289
GCLIB_DLL_EXPORTED GReturn GCALL GCmd(GCon g, GCStringIn command)
Wrapper around GCommand for use when the return value is not desired.
Definition: gclibo.c:237
GCLIB_DLL_EXPORTED 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...
Definition: gclibo.c:54
#define G_BAD_RESPONSE_QUESTION_MARK
Operation received a ?, indicating controller has a TC error.
Definition: gclib_errors.h:70
#define G_WRITE_ERROR
Device write failed. E.G. Socket was closed by remote host. See G_UTIL_GCAPS_KEEPALIVE.
Definition: gclib_errors.h:40
#define G_DATA_RECORD_ERROR
Data record error, e.g. DR attempted on serial connection.
Definition: gclib_errors.h:49
#define G_COMMAND_CALLED_WITH_ILLEGAL_COMMAND
GCommand() was called with an illegal command, e.g. ED, DL or QD.
Definition: gclib_errors.h:46
int GReturn
Every function returns a value of type GReturn. See gclib_errors.h for possible values.
Definition: gclib.h:93
#define G_BAD_VALUE_RANGE
Bad value or range, e.g. GCon g variable passed to function was bad.
Definition: gclib_errors.h:73
#define G_UTIL_INFO
GUtility(), get a connection info string.
Definition: gclib.h:63
int GOption
Option integer for various formatting, etc.
Definition: gclib.h:96
#define G_BAD_FIRMWARE_LOAD
Bad firmware upgrade.
Definition: gclib_errors.h:88
#define POLLINGINTERVAL
Interval, in milliseconds, for polling commands, e.g. GWaitForBool().
Definition: gclibo.h:40
#define G_SMALL_BUFFER
Most reads from Galil are small. This value will easily hold most, e.g. TH, TZ, etc.
Definition: gclib.h:89
#define G_GCLIB_ERROR
General library error. Indicates internal API caught an unexpected error. Contact Galil support if th...
Definition: gclib_errors.h:16
#define G_GCAPS_OPEN_ERROR
gcaps connection couldn't open. Server is not running or is not reachable.
Definition: gclib_errors.h:91
#define G_OPEN_ERROR
Device could not be opened. E.G. Serial port or PCI device already open.
Definition: gclib_errors.h:34
#define G_NO_ERROR
Return value if function succeeded.
Definition: gclib_errors.h:13
#define G_INVALID_PREPROCESSOR_OPTIONS
GProgramDownload was called with a bad preprocessor directive.
Definition: gclib_errors.h:43
#define G_UTIL_GCAPS_IPREQUEST
GUtility(), get a list of hardware requesting IPs from the gcaps server.
Definition: gclib.h:76
#define G_UTIL_GCAPS_PUBLISH_SERVER
GUtility(), make local gcaps server discoverable by other gcaps servers on the local network.
Definition: gclib.h:80
#define G_BAD_FULL_MEMORY
Not enough memory for an operation, e.g. all connections allowed for a process already taken.
Definition: gclib_errors.h:76
unsigned int GSize
Size of buffers, etc.
Definition: gclib.h:95
#define GCALL
Specify calling convention for Windows.
Definition: gclib.h:38
#define G_UTIL_PING
GUtility(), uses ICMP ping to determine if an IP address is reachable and assigned.
Definition: gclib.h:69
#define G_UTIL_VERSION
GUtility(), get a library version string.
Definition: gclib.h:62
#define G_UTIL_GCAPS_PING
GUtility(), uses ICMP ping to determine if an IP address is reachable and assigned....
Definition: gclib.h:78
#define G_UTIL_IPREQUEST
GUtility(), get a list of hardware requesting IPs.
Definition: gclib.h:66
#define G_ARRAY_NOT_DIMENSIONED
Array operation was called on an array that was not in the controller's array table,...
Definition: gclib_errors.h:58
#define MAXPROG
Maximum size for a program.
Definition: gclibo.h:38
#define G_UTIL_GCAPS_SERVER_STATUS
GUtility(), get information on the local server's name and if it is published to the local network.
Definition: gclib.h:82
#define G_UTIL_ASSIGN
GUtility(), assign IP addresses over the network.
Definition: gclib.h:67
#define G_UTIL_TIMEOUT_OVERRIDE
GUtility(), read/write access to timeout override.
Definition: gclib.h:60
#define G_FIRMWARE_LOAD_NOT_SUPPORTED
Firmware is not supported on this bus, e.g. Ethernet for the DMC-21x3 series.
Definition: gclib_errors.h:55
#define G_UTIL_GCAPS_ADDRESSES
GUtility(), get a list of available connections from the gcaps server.
Definition: gclib.h:75
#define G_UTIL_ADDRESSES
GUtility(), get a list of available connections.
Definition: gclib.h:65
#define G_BAD_ADDRESS
Bad address.
Definition: gclib_errors.h:85
void * GCon
Connection handle. Unique for each connection in process. Assigned a non-zero value in GOpen().
Definition: gclib.h:94
#define G_GCAPS_SUBSCRIPTION_ERROR
GMessage(), GRecord(), GInterrupt() called on a connection without –subscribe switch.
Definition: gclib_errors.h:94
#define G_UTIL_GCAPS_ASSIGN
GUtility(), assign IP addresses over the network from the gcaps server.
Definition: gclib.h:77
#define G_CONNECTION_NOT_ESTABLISHED
Function was called with no connection.
Definition: gclib_errors.h:61
#define G_GCLIB_UTILITY_ERROR
An invalid request value was specified to GUtility.
Definition: gclib_errors.h:19
#define G_UTIL_SLEEP
GUtility(), specify an interval to sleep.
Definition: gclib.h:64
#define G_UNSUPPORTED_FUNCTION
Function cannot be called on this bus. E.G. GInterrupt() on serial.
Definition: gclib_errors.h:52
#define G_UTIL_GCAPS_SET_SERVER
GUtility(), set the new active gcaps server.
Definition: gclib.h:81
#define G_BAD_FILE
Bad file path, bad file contents, or bad write.
Definition: gclib_errors.h:82
#define G_GCLIB_POLLING_FAILED
GWaitForBool out of polling trials.
Definition: gclib_errors.h:28
#define G_READ_ERROR
Device read failed. E.G. Socket was closed by remote host. See G_UTIL_GCAPS_KEEPALIVE.
Definition: gclib_errors.h:37
#define G_BAD_LOST_DATA
Lost data, e.g. GCommand() response buffer was too small for the controller's response.
Definition: gclib_errors.h:79
#define G_UTIL_GCAPS_LIST_SERVERS
GUtility(), get a list of all available gcaps servers on the local network.
Definition: gclib.h:79
#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 ...
Definition: gclib_errors.h:25
char * GCStringOut
C-string output from the library. Implies null-termination.
Definition: gclib.h:97
const char * GCStringIn
C-string input to the library. Implies null-termination.
Definition: gclib.h:98
#define G_UNABLE_TO_COMPRESS_PROGRAM_TO_FIT
Program preprocessor could not compress the program within the user's constraints.
Definition: gclib_errors.h:67
#define G_GCLIB_UTILITY_IP_TAKEN
The IP cannot be assigned because ping returned a reply.
Definition: gclib_errors.h:22
#define G_UTIL_GCAPS_VERSION
GUtility(), get the version of the gcaps server.
Definition: gclib.h:73
#define G_TIMEOUT
Operation timed out. Timeout is set by the –timeout option in GOpen() and can be overriden by GSettin...
Definition: gclib_errors.h:31
#define G_UTIL_GCAPS_REMOTE_CONNECTIONS
GUtility(), get a list of remote addresses connected to local server.
Definition: gclib.h:83
#define G_ILLEGAL_DATA_IN_PROGRAM
Data to download not valid, e.g. \ in data.
Definition: gclib_errors.h:64
#define G_LINE_BUFFER
For writes, via command interpreter, to the Galil.
Definition: gclib.h:91
void error(GCon g, GReturn rc)
An example of error handling and debugging information.
Definition: examples.h:40