| gclib 1.35.5 Communications API for Galil controllers and PLCs |

gclib.h
Go to the documentation of this file.
1
20 #ifndef I_D48432D9_1FA3_4C7D_B44C_05F8B9000ADF
21 #define I_D48432D9_1FA3_4C7D_B44C_05F8B9000ADF
22
23 //set library visibility for gcc and msvc
24 #if BUILDING_GCLIB && HAVE_VISIBILITY
25 #define GCLIB_DLL_EXPORTED __attribute__((__visibility__("default")))
26 #elif BUILDING_GCLIB && defined _MSC_VER
27 #define GCLIB_DLL_EXPORTED __declspec(dllexport)
28 #elif defined _MSC_VER
29 #define GCLIB_DLL_EXPORTED __declspec(dllimport)
30 #else
31 #define GCLIB_DLL_EXPORTED
32 #endif
33
34 #include "gclib_record.h" // Galil data record structs and unions.
35 #include "gclib_errors.h" // GReturn error code values and strings.
36
37 #ifdef _WIN32
38 #define GCALL __stdcall
39 #else
40 #define GCALL
41 #endif
42
43 //#define G_USE_GCOMPOUND //!< GCompound() is not part of the standard gclib release. Contact Galil Applications for a special build, http://galil.com/contact.
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49 //Constants for function arguments
50 #define G_DR 1
51 #define G_QR 0
52 #define G_BOUNDS -1
53 #define G_CR 0
54 #define G_COMMA 1
55 #define G_PUBLISH_SERVER 1
56 #define G_REMOVE_SERVER 0
57
58 //Constants for GUtility()
59 #define G_UTIL_TIMEOUT 1
60 #define G_UTIL_TIMEOUT_OVERRIDE 2
61 #define G_USE_INITIAL_TIMEOUT -1
62 #define G_UTIL_VERSION 128
63 #define G_UTIL_INFO 129
64 #define G_UTIL_SLEEP 130
65 #define G_UTIL_ADDRESSES 131
66 #define G_UTIL_IPREQUEST 132
67 #define G_UTIL_ASSIGN 133
68 #define G_UTIL_DEVICE_INITIALIZE 134
69 #define G_UTIL_PING 135
70 #define G_UTIL_ERROR_CONTEXT 136
71
72 #define G_UTIL_GCAPS_HOST 256
73 #define G_UTIL_GCAPS_VERSION 257
74 #define G_UTIL_GCAPS_KEEPALIVE 258
75 #define G_UTIL_GCAPS_ADDRESSES 259
76 #define G_UTIL_GCAPS_IPREQUEST 260
77 #define G_UTIL_GCAPS_ASSIGN 261
78 #define G_UTIL_GCAPS_PING 262
79 #define G_UTIL_GCAPS_LIST_SERVERS 263
80 #define G_UTIL_GCAPS_PUBLISH_SERVER 264
81 #define G_UTIL_GCAPS_SET_SERVER 265
82 #define G_UTIL_GCAPS_SERVER_STATUS 266
83 #define G_UTIL_GCAPS_REMOTE_CONNECTIONS 267
84 #define G_UTIL_GCAPS_SERVER_INFO 268
85 #define G_UTIL_GCAPS_ADDRESSES_GET_REMEMBERED 269
86 #define G_UTIL_GCAPS_ADDRESSES_SET_REMEMBERED 270
87
88 //Convenience constants
89 #define G_SMALL_BUFFER 1024
90 #define G_HUGE_BUFFER 524288
91 #define G_LINE_BUFFER 80
92
93 typedef int GReturn;
94 typedef void* GCon;
95 typedef unsigned int GSize;
96 typedef int GOption;
97 typedef char* GCStringOut;
98 typedef const char* GCStringIn;
99 typedef char* GBufOut;
100 typedef const char* GBufIn;
101 typedef unsigned char GStatus;
102 typedef void* GMemory;
103
105 GCLIB_DLL_EXPORTED GReturn GCALL GOpen(GCStringIn address, GCon* g);
152 GCLIB_DLL_EXPORTED GReturn GCALL GClose(GCon g);
172 GCLIB_DLL_EXPORTED GReturn GCALL GLost(GCon g);
189 GCLIB_DLL_EXPORTED GReturn GCALL GRead(GCon g, GBufOut buffer, GSize buffer_len, GSize* bytes_read);
210 GCLIB_DLL_EXPORTED GReturn GCALL GWrite(GCon g, GBufIn buffer, GSize buffer_len);
227 GCLIB_DLL_EXPORTED GReturn GCALL GCommand(GCon g, GCStringIn command, GBufOut buffer, GSize buffer_len, GSize* bytes_returned);
244 GCLIB_DLL_EXPORTED GReturn GCALL GProgramDownload(GCon g, GCStringIn program, GCStringIn preprocessor);
260 GCLIB_DLL_EXPORTED GReturn GCALL GProgramUpload(GCon g, GBufOut buffer, GSize buffer_len);
273 GCLIB_DLL_EXPORTED GReturn GCALL GArrayDownload(GCon g, const GCStringIn array_name, GOption first, GOption last, GCStringIn buffer);
290 GCLIB_DLL_EXPORTED GReturn GCALL GArrayUpload(GCon g, const GCStringIn array_name, GOption first, GOption last, GOption delim, GBufOut buffer, GSize buffer_len);
307 GCLIB_DLL_EXPORTED GReturn GCALL GRecord(GCon g, union GDataRecord* record, GOption method);
334 GCLIB_DLL_EXPORTED GReturn GCALL GMessage(GCon g, GCStringOut buffer, GSize buffer_len);
367 GCLIB_DLL_EXPORTED GReturn GCALL GInterrupt(GCon g, GStatus* status_byte);
389 GCLIB_DLL_EXPORTED GReturn GCALL GFirmwareDownload(GCon g, GCStringIn filepath);
410 GCLIB_DLL_EXPORTED GReturn GCALL GUtility(GCon g, GOption request, GMemory memory1, GMemory memory2);
516 #ifdef G_USE_GCOMPOUND
518 GCLIB_DLL_EXPORTED GReturn GCALL GCompound(GCon g, GCStringIn buffer);
563 #endif
564
565 #ifdef __cplusplus
566 } //extern "C"
567 #endif
568
569 #endif //I_D48432D9_1FA3_4C7D_B44C_05F8B9000ADF
gclib_errors.h
gclib_record.h
GUtility
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.
GFirmwareDownload
GCLIB_DLL_EXPORTED GReturn GCALL GFirmwareDownload(GCon g, GCStringIn filepath)
Upgrade firmware.
GRecord
GCLIB_DLL_EXPORTED GReturn GCALL GRecord(GCon g, union GDataRecord *record, GOption method)
Provides a fresh copy of the controller's data record. Data is cast into a union, GDataRecord.
GClose
GCLIB_DLL_EXPORTED GReturn GCALL GClose(GCon g)
Closes a connection to a Galil Controller.
GCommand
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.
GInterrupt
GCLIB_DLL_EXPORTED GReturn GCALL GInterrupt(GCon g, GStatus *status_byte)
Provides access to PCI and UDP interrupts from the controller.
GWrite
GCLIB_DLL_EXPORTED GReturn GCALL GWrite(GCon g, GBufIn buffer, GSize buffer_len)
Performs a write on the connection.
GArrayDownload
GCLIB_DLL_EXPORTED GReturn GCALL GArrayDownload(GCon g, const GCStringIn array_name, GOption first, GOption last, GCStringIn buffer)
Downloads array data to a pre-dimensioned array in the controller's array table.
GProgramUpload
GCLIB_DLL_EXPORTED GReturn GCALL GProgramUpload(GCon g, GBufOut buffer, GSize buffer_len)
Uploads a program from the controller's program buffer.
GLost
GCLIB_DLL_EXPORTED GReturn GCALL GLost(GCon g)
Checks for a lost connection.
GMessage
GCLIB_DLL_EXPORTED GReturn GCALL GMessage(GCon g, GCStringOut buffer, GSize buffer_len)
Provides access to unsolicited messages from the controller.
GProgramDownload
GCLIB_DLL_EXPORTED GReturn GCALL GProgramDownload(GCon g, GCStringIn program, GCStringIn preprocessor)
Downloads a program to the controller's program buffer.
GRead
GCLIB_DLL_EXPORTED GReturn GCALL GRead(GCon g, GBufOut buffer, GSize buffer_len, GSize *bytes_read)
Performs a read on the connection.
GOpen
GCLIB_DLL_EXPORTED GReturn GCALL GOpen(GCStringIn address, GCon *g)
Open a connection to a Galil Controller.
GArrayUpload
GCLIB_DLL_EXPORTED GReturn GCALL GArrayUpload(GCon g, const GCStringIn array_name, GOption first, GOption last, GOption delim, GBufOut buffer, GSize buffer_len)
Uploads array data from the controller's array table.
GBufIn
const char * GBufIn
Data input to the library. No null-termination, function will have a GSize to indicate bytes to write...
Definition: gclib.h:100
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
GStatus
unsigned char GStatus
Interrupt status byte.
Definition: gclib.h:101
GSize
unsigned int GSize
Size of buffers, etc.
Definition: gclib.h:95
GCALL
#define GCALL
Specify calling convention for Windows.
Definition: gclib.h:38
GBufOut
char * GBufOut
Data output from the library. No null-termination implied. Returned values may be null-terminated,...
Definition: gclib.h:99
GCon
void * GCon
Connection handle. Unique for each connection in process. Assigned a non-zero value in GOpen().
Definition: gclib.h:94
GMemory
void * GMemory
Pointer to untyped memory for use in GUtility().
Definition: gclib.h:102
GCStringOut
char * GCStringOut
C-string output from the library. Implies null-termination.
Definition: gclib.h:97
GCStringIn
const char * GCStringIn
C-string input to the library. Implies null-termination.
Definition: gclib.h:98
GDataRecord
Data record union, containing all structs and a generic byte array accessor.
Definition: gclib_record.h:1083