| gclib 424 Communications API for Galil controllers and PLCs |

gclib.h
Go to the documentation of this file.
1
6 #ifndef I_D48432D9_1FA3_4C7D_B44C_05F8B9000ADF
7 #define I_D48432D9_1FA3_4C7D_B44C_05F8B9000ADF
8
9 //set library visibility for gcc and msvc
10 #if BUILDING_GCLIB && HAVE_VISIBILITY
11 #define GCLIB_DLL_EXPORTED __attribute__((__visibility__("default")))
12 #elif BUILDING_GCLIB && defined _MSC_VER
13 #define GCLIB_DLL_EXPORTED __declspec(dllexport)
14 #elif defined _MSC_VER
15 #define GCLIB_DLL_EXPORTED __declspec(dllimport)
16 #else
17 #define GCLIB_DLL_EXPORTED
18 #endif
19
20 #include "gclib_record.h" // Galil data record structs and unions.
21 #include "gclib_errors.h" // GReturn error code values and strings.
22
23 #ifdef _WIN32
24 #define GCALL __stdcall
25 #else
26 #define GCALL
27 #endif
28
29 //#define G_USE_GCOMPOUND //!< GCompound() is not part of the standard gclib release. Contact Galil Applications for a special build, http://galil.com/contact.
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 //Constants for function arguments
36 #define G_DR 1
37 #define G_QR 0
38 #define G_BOUNDS -1
39 #define G_CR 0
40 #define G_COMMA 1
41
42 //Constants for GUtility()
43 #define G_UTIL_TIMEOUT 1
44 #define G_UTIL_TIMEOUT_OVERRIDE 2
45 #define G_USE_INITIAL_TIMEOUT -1
46 #define G_UTIL_VERSION 128
47 #define G_UTIL_INFO 129
48 #define G_UTIL_SLEEP 130
49 #define G_UTIL_ADDRESSES 131
50 #define G_UTIL_IPREQUEST 132
51 #define G_UTIL_ASSIGN 133
52 #define G_UTIL_DEVICE_INITIALIZE 134
53 #define G_UTIL_PING 135
54 #define G_UTIL_ERROR_CONTEXT 136
55
56 #define G_UTIL_GCAPS_HOST 256
57 #define G_UTIL_GCAPS_VERSION 257
58 #define G_UTIL_GCAPS_KEEPALIVE 258
59 #define G_UTIL_GCAPS_ADDRESSES 259
60 #define G_UTIL_GCAPS_IPREQUEST 260
61 #define G_UTIL_GCAPS_ASSIGN 261
62 #define G_UTIL_GCAPS_PING 262
63
64
65 //Convenience constants
66 #define G_SMALL_BUFFER 1024
67 #define G_HUGE_BUFFER 524288
68
69 typedef int GReturn;
70 typedef void* GCon;
71 typedef unsigned int GSize;
72 typedef int GOption;
73 typedef char* GCStringOut;
74 typedef const char* GCStringIn;
75 typedef char* GBufOut;
76 typedef const char* GBufIn;
77 typedef unsigned char GStatus;
78 typedef void* GMemory;
79
81 GCLIB_DLL_EXPORTED GReturn GCALL GOpen(GCStringIn address, GCon* g);
127 GCLIB_DLL_EXPORTED GReturn GCALL GClose(GCon g);
147 GCLIB_DLL_EXPORTED GReturn GCALL GRead(GCon g, GBufOut buffer, GSize buffer_len, GSize* bytes_read);
168 GCLIB_DLL_EXPORTED GReturn GCALL GWrite(GCon g, GBufIn buffer, GSize buffer_len);
185 GCLIB_DLL_EXPORTED GReturn GCALL GCommand(GCon g, GCStringIn command, GBufOut buffer, GSize buffer_len, GSize* bytes_returned);
202 GCLIB_DLL_EXPORTED GReturn GCALL GProgramDownload(GCon g, GCStringIn program, GCStringIn preprocessor);
218 GCLIB_DLL_EXPORTED GReturn GCALL GProgramUpload(GCon g, GBufOut buffer, GSize buffer_len);
231 GCLIB_DLL_EXPORTED GReturn GCALL GArrayDownload(GCon g, const GCStringIn array_name, GOption first, GOption last, GCStringIn buffer);
248 GCLIB_DLL_EXPORTED GReturn GCALL GArrayUpload(GCon g, const GCStringIn array_name, GOption first, GOption last, GOption delim, GBufOut buffer, GSize buffer_len);
265 GCLIB_DLL_EXPORTED GReturn GCALL GRecord(GCon g, union GDataRecord* record, GOption method);
292 GCLIB_DLL_EXPORTED GReturn GCALL GMessage(GCon g, GCStringOut buffer, GSize buffer_len);
325 GCLIB_DLL_EXPORTED GReturn GCALL GInterrupt(GCon g, GStatus* status_byte);
347 GCLIB_DLL_EXPORTED GReturn GCALL GFirmwareDownload(GCon g, GCStringIn filepath);
368 GCLIB_DLL_EXPORTED GReturn GCALL GUtility(GCon g, GOption request, GMemory memory1, GMemory memory2);
482 #ifdef G_USE_GCOMPOUND
483 GCLIB_DLL_EXPORTED GReturn GCALL GCompound(GCon g, GCStringIn buffer);
529 #endif
530
531 #ifdef __cplusplus
532 } //extern "C"
533 #endif
534
535 #endif //I_D48432D9_1FA3_4C7D_B44C_05F8B9000ADF
GOption
int GOption
Option integer for various formatting, etc.
Definition: gclib.h:72
GSize
unsigned int GSize
Size of buffers, etc.
Definition: gclib.h:71
GOpen
GCLIB_DLL_EXPORTED GReturn GCALL GOpen(GCStringIn address, GCon *g)
Open a connection to a Galil Controller.
GWrite
GCLIB_DLL_EXPORTED GReturn GCALL GWrite(GCon g, GBufIn buffer, GSize buffer_len)
Performs a write on the connection.
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...
GMemory
void * GMemory
Pointer to untyped memory for use in GUtility().
Definition: gclib.h:78
GRead
GCLIB_DLL_EXPORTED GReturn GCALL GRead(GCon g, GBufOut buffer, GSize buffer_len, GSize *bytes_read)
Performs a read on the connection.
GBufOut
char * GBufOut
Data output from the library. No null-termination implied. Returned values may be null-terminated...
Definition: gclib.h:75
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&#39;s array table.
GMessage
GCLIB_DLL_EXPORTED GReturn GCALL GMessage(GCon g, GCStringOut buffer, GSize buffer_len)
Provides access to unsolicited messages from the controller.
gclib_record.h
GInterrupt
GCLIB_DLL_EXPORTED GReturn GCALL GInterrupt(GCon g, GStatus *status_byte)
Provides access to PCI and UDP interrupts from the controller.
GFirmwareDownload
GCLIB_DLL_EXPORTED GReturn GCALL GFirmwareDownload(GCon g, GCStringIn filepath)
Upgrade firmware.
GCon
void * GCon
Connection handle. Unique for each connection in process. Assigned a non-zero value in GOpen()...
Definition: gclib.h:70
GProgramDownload
GCLIB_DLL_EXPORTED GReturn GCALL GProgramDownload(GCon g, GCStringIn program, GCStringIn preprocessor)
Downloads a program to the controller&#39;s program buffer.
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&#39;s array table.
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.
GProgramUpload
GCLIB_DLL_EXPORTED GReturn GCALL GProgramUpload(GCon g, GBufOut buffer, GSize buffer_len)
Uploads a program from the controller&#39;s program buffer.
GReturn
int GReturn
Every function returns a value of type GReturn. See gclib_errors.h for possible values.
Definition: gclib.h:69
GCStringIn
const char * GCStringIn
C-string input to the library. Implies null-termination.
Definition: gclib.h:74
GRecord
GCLIB_DLL_EXPORTED GReturn GCALL GRecord(GCon g, union GDataRecord *record, GOption method)
Provides a fresh copy of the controller&#39;s data record. Data is cast into a union, GDataRecord...
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:76
GStatus
unsigned char GStatus
Interrupt status byte.
Definition: gclib.h:77
GClose
GCLIB_DLL_EXPORTED GReturn GCALL GClose(GCon g)
Closes a connection to a Galil Controller.
GCStringOut
char * GCStringOut
C-string output from the library. Implies null-termination.
Definition: gclib.h:73
GCALL
#define GCALL
Specify calling convention for Windows.
Definition: gclib.h:24
gclib_errors.h
GDataRecord
Data record union, containing all structs and a generic byte array accessor.
Definition: gclib_record.h:1029