gclib 2.0.9
Communications API for Galil controllers and PLCs
 
Loading...
Searching...
No Matches
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
24void 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;
34 return rc;
35
36#ifdef G_USE_GCAPS
37 str_len = strlen(ver) + 1;
39 if (ver_len > 0
41 {
42 ver[str_len - 1] = ' '; //add a delimiter
43 }
44#endif
45
46 return rc;
47}
48
53
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
65GReturn 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
107{
108 GReturn rc;
109#ifdef G_USE_GCAPS
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);
120 }
121 }
122#endif
123
124 //non-gcaps version opens port listens for 5 seconds, and closes
126}
127
129{
130 GReturn rc;
131#ifdef G_USE_GCAPS
133#else
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{
152#ifdef G_USE_GCAPS
154#else
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
174#else
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
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
218{
219 GReturn rc;
220#ifdef G_USE_GCAPS
222#else
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
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 {
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 {
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
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
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
319{
320 char cmd[G_LINE_BUFFER];
321 char buf[G_LINE_BUFFER];
322 int rc;
323 strcpy(cmd, "MG (");
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
340}
341
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;
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
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;
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
447 {
450 rc = G_BAD_FILE;
451 }
452
453 fclose(file);
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_ALREADY_OPEN:
494 error_message = G_ALREADY_OPEN_S;
495 break;
496
497 case G_READ_ERROR:
498 error_message = G_READ_ERROR_S;
499 break;
500
501 case G_WRITE_ERROR:
502 error_message = G_WRITE_ERROR_S;
503 break;
504
506 error_message = G_COMMAND_CALLED_WITH_ILLEGAL_COMMAND_S;
507 break;
508
510 error_message = G_DATA_RECORD_ERROR_S;
511 break;
512
514 error_message = G_UNSUPPORTED_FUNCTION_S;
515 break;
516
517 case G_BAD_ADDRESS:
518 error_message = G_BAD_ADDRESS_S;
519 break;
520
522 error_message = G_BAD_FIRMWARE_LOAD_S;
523 break;
524
526 error_message = G_FIRMWARE_LOAD_NOT_SUPPORTED_S;
527 break;
528
530 error_message = G_ARRAY_NOT_DIMENSIONED_S;
531 break;
532
534 error_message = G_CONNECTION_NOT_ESTABLISHED_S;
535 break;
536
538 error_message = G_ILLEGAL_DATA_IN_PROGRAM_S;
539 break;
540
542 error_message = G_UNABLE_TO_COMPRESS_PROGRAM_TO_FIT_S;
543 break;
544
546 error_message = G_INVALID_PREPROCESSOR_OPTIONS_S;
547 break;
548
550 error_message = G_BAD_RESPONSE_QUESTION_MARK_S;
551 break;
552
554 error_message = G_BAD_VALUE_RANGE_S;
555 break;
556
558 error_message = G_BAD_FULL_MEMORY_S;
559 break;
560
561 case G_BAD_LOST_DATA:
562 error_message = G_BAD_LOST_DATA_S;
563 break;
564
565 case G_BAD_FILE:
566 error_message = G_BAD_FILE_S;
567 break;
568
570 error_message = G_GCAPS_OPEN_ERROR_S;
571 break;
572
574 error_message = G_GCAPS_SUBSCRIPTION_ERROR_S;
575 break;
576
577 default:
578 error_message = "internal error";
579 break;
580 }
581
583 error[error_len - 1] = 0; //ensure null termination
584}
585
586#ifdef GCLIB_LOGGING
587void LogMsg(const char* msg)
588{
590 struct tm * timeinfo;
591
592 time(&rawtime);
594 char* time_string = asctime(timeinfo);
595
596#ifdef _WIN32
597 const char* filename = "C:/ProgramData/Galil/gcaps/gclib_mdns_log.txt";
598#else
599 const char* filename = "/var/tmp/gclib_mdns_log.txt";
600#endif // _WIN32
601
602 FILE *logfile;
603 logfile = fopen(filename, "a");
604 fprintf(logfile, "%s | %s", msg, time_string);
606}
607#endif
608
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
#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.
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
#define G_WRITE_ERROR
Device write failed. E.G. Socket was closed by remote host. See G_UTIL_GCAPS_KEEPALIVE.
#define G_DATA_RECORD_ERROR
Data record error, e.g. DR attempted on serial connection.
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
#define G_COMMAND_CALLED_WITH_ILLEGAL_COMMAND
GCommand() was called with an illegal command, e.g. ED, DL or QD.
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.
#define G_UTIL_INFO
GUtility(), get a connection info string.
Definition gclib.h:63
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
int GOption
Option integer for various formatting, etc.
Definition gclib.h:96
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
#define G_BAD_FIRMWARE_LOAD
Bad firmware upgrade.
#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
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
#define G_ALREADY_OPEN
Serial or PCI file has a flock placed on it, presumably by another gclib connection.
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
#define G_GCLIB_ERROR
General library error. Indicates internal API caught an unexpected error. Contact Galil support if th...
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
#define G_GCAPS_OPEN_ERROR
gcaps connection couldn't open. Server is not running or is not reachable.
#define G_OPEN_ERROR
Device could not be opened. E.G. Serial port or PCI device already open.
#define G_NO_ERROR
Return value if function succeeded.
#define G_INVALID_PREPROCESSOR_OPTIONS
GProgramDownload was called with a bad preprocessor directive.
#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
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.
#define G_BAD_FULL_MEMORY
Not enough memory for an operation, e.g. all connections allowed for a process already taken.
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
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,...
#define MAXPROG
Maximum size for a program.
Definition gclibo.h:38
GCLIB_DLL_EXPORTED GReturn GCALL GProgramUpload(GCon g, GBufOut buffer, GSize buffer_len)
Uploads a program from the controller's program buffer.
#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.
#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.
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.
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
#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.
GCLIB_DLL_EXPORTED GReturn GCALL GProgramUploadFile(GCon g, GCStringIn file_path)
Program upload to file.
Definition gclibo.c:430
#define G_GCLIB_UTILITY_ERROR
An invalid request value was specified to GUtility.
#define G_UTIL_SLEEP
GUtility(), specify an interval to sleep.
Definition gclib.h:64
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
#define G_UNSUPPORTED_FUNCTION
Function cannot be called on this bus. E.G. GInterrupt() on serial.
#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.
#define G_GCLIB_POLLING_FAILED
GWaitForBool out of polling trials.
#define G_READ_ERROR
Device read failed. E.G. Socket was closed by remote host. See G_UTIL_GCAPS_KEEPALIVE.
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
#define G_BAD_LOST_DATA
Lost data, e.g. GCommand() response buffer was too small for the controller's response.
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
#define G_UTIL_GCAPS_LIST_SERVERS
GUtility(), get a list of all available gcaps servers on the local network.
Definition gclib.h:79
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
#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 ...
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
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
#define G_UNABLE_TO_COMPRESS_PROGRAM_TO_FIT
Program preprocessor could not compress the program within the user's constraints.
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_GCLIB_UTILITY_IP_TAKEN
The IP cannot be assigned because ping returned a reply.
#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...
#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.
#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
GReturn vector(GCon g, char *file)
Puts controller into Vector Mode and accepts a file defining vector points.
Definition vector.cpp:36