gclib  437
Communications API for Galil controllers and PLCs
gcc.md
1 # gcc (Linux) {#gcc}
2 
3 The following instructions were performed on
4 
5  $ uname -a
6  Linux localhost.localdomain 3.17.4-301.fc21.x86_64 #1 SMP Thu Nov 27 19:09:10 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
7  $ g++ --version
8  g++ (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)
9 
10 ## Copy Files
11 
12  $ mkdir test
13  $ cd test
14  $ tar -xzf /usr/share/doc/gclib/src/gclib_examples.tar.gz
15  $ ls
16  x_arrays.cpp x_gcommand.cpp x_gmotioncomplete.cpp x_programs.cpp
17  x_examples.cpp x_ginterrupt.cpp x_gread_gwrite.cpp x_simple.c
18  x_examples.h x_gmessage.cpp x_grecord.cpp
19 
20 ## x_simple.c
21 
22 * In a text editor, open *x_simple.c*. Find the GOpen() call and update the address to match the desired hardware. See the documentation for GOpen() for address formatting options.
23 
24 ### Compile
25 
26  $ gcc -Wall -Werror x_simple.c -lgclib -lgclibo -o simple
27 
28 ### Run
29 
30  $ ./simple
31  rc: 0
32  version: 85.60.131
33  rc: 0
34  rc: 0
35  info: 10.1.3.17, DMC4020 Rev 1.2b, 291
36  rc: 0
37  response: 179340166.0000
38  :
39 
40 ## x_examples.cpp
41 * In a text editor, open *x_examples.cpp*. Find the GOpen() call and update the address to match the desired hardware. See the documentation for GOpen() for address formatting options. Don't forget `-s ALL` if data records, interrupts, and messages are to be tested.
42 * Find the `#if 0` preprocessor block enclosing the example calls. Change to `#if 1` to run the examples. Comment out the function calls to be avoided. Note some calls attempt to move motors and not all functions are compatible with all Galil products.
43 
44 ### Compile
45 
46  $ g++ x_*.cpp -lgclib -lgclibo -o example
47 
48 ### Run
49  $./example
50  Library version: 85.60.131
51 
52 
53  10.1.3.17, DMC4020 Rev 1.2b, 291
54 
55  ************************************************************************
56  Example GRead() and GWrite() usage
57  ************************************************************************
58 
59  Read 155 QR bytes.
60 
61  ************************************************************************
62  Example GCommand() usage
63  ************************************************************************
64  Revision report, ^R^V
65  DMC4020 Rev 1.2b
66  :
67 
68  Command Values
69  val is 10
70  val is 11
71  val is 3.1415
72  val is 9.869
73 
74  Command Trimming
75  > 179798738.0000
76  :<
77  > 179798738.0000<
78  >179798738.0000<
79 
80  Receiving Binary Data
81  QR read 155 bytes
82 
83  Error handling
84  QD correctly trapped, not allowed, try GArrayDownload()
85  DL correctly trapped, not allowed, try GProgramDownload()
86 
87  Modifying timeout
88  Burning program...OK
89 
90  ************************************************************************
91  Example GProgramDownload() and GProgramUpload() usage
92  ************************************************************************
93  GProgramDownload() correctly errored. Can't fit with level 3 compression
94  Program Downloaded with compression level 4
95  Uploading program:
96  #A;i=0;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1
97  i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;EN
98 
99  Program executed as expected
100  ************************************************************************
101  Example GArrayDownload(), GArrayUploadFile()
102  GArrayDownloadFile(), and GArrayUpload usage
103  ************************************************************************
104  2.0000, 4.0000, 6.0000, 8.0000, 10.0000, 12.0000, 14.0000, 16.0000, 18.0000, 20.0000
105 
106  2.0000, 1.0000, 3.0000, 5.0000, 10.0000, 12.0000, 14.0000, 16.0000, 18.0000, 20.0000
107 
108  3.0000, 5.0000, 10.0000
109  2.0000, 1.0000, 3.0000, 5.0000, 10.0000, 12.0000, 14.0000, 16.0000, 18.0000, 20.0000
110 
111 
112  ************************************************************************
113  Example GRecord() usage
114  ************************************************************************
115 
116  QR-based data record
117  36100
118  6000
119 
120  DR-based data record
121  36204
122  36306
123  36408
124  36510
125  36612
126  36714
127  36816
128  36918
129  37020
130  37122
131  37224
132 
133  QR-based data record with offsets
134  37224
135  37224
136 
137  ************************************************************************
138  Example GMessage() usage
139  ************************************************************************
140  0.0000
141  1.0000
142  2.0000
143  3.0000
144  4.0000
145  5.0000
146  6.0000
147  7.0000
148  8.0000
149  9.0000
150 
151  ************************************************************************
152  Example GInterrupt() usage
153  ************************************************************************
154  "UI 8" executed.
155 
156  ************************************************************************
157  Example GMotionComplete() usage
158  ************************************************************************
159 
160  Position: 0, 0
161  Beginning independent motion... Motion Complete on A
162  Position: 8000, 0
163 
164  Position: 0, 0
165  Beginning vector motion... Motion Complete on vector plane S
166  Position: 6000, 0
167 
168 
169  examples.cpp executed OK
170  main() is finished. Press Enter to exit:
171