gclib  437
Communications API for Galil controllers and PLCs
borland.md
1 # Borland C++ {#borland}
2 
3 The following instructions were performed on:
4 
5  Embarcadero C++ 7.10 for Win32 Copyright (c) 1993-2015 Embarcadero Technologies, Inc.
6 
7 For brevity, these instructions assume the default installation location of "C:\Program Files (x86)\Galil\gclib".
8 
9 ## Copy Files
10 Copy "gclib\examples\borland" to a convenient, writable location, e.g. "C:\temp". Run `C:\temp\borland\copy_source.bat` to copy all files.
11 
12  C:\temp>cd borland
13 
14  C:\temp\borland>copy_source.bat
15  \Program Files (x86)\Galil\gclib\examples\cpp\x_arrays.cpp
16  \Program Files (x86)\Galil\gclib\examples\cpp\x_examples.cpp
17  \Program Files (x86)\Galil\gclib\examples\cpp\x_examples.h
18  \Program Files (x86)\Galil\gclib\examples\cpp\x_gcommand.cpp
19  \Program Files (x86)\Galil\gclib\examples\cpp\x_ginterrupt.cpp
20  \Program Files (x86)\Galil\gclib\examples\cpp\x_gmessage.cpp
21  \Program Files (x86)\Galil\gclib\examples\cpp\x_gmotioncomplete.cpp
22  \Program Files (x86)\Galil\gclib\examples\cpp\x_gread_gwrite.cpp
23  \Program Files (x86)\Galil\gclib\examples\cpp\x_grecord.cpp
24  \Program Files (x86)\Galil\gclib\examples\cpp\x_nonblocking.cpp
25  \Program Files (x86)\Galil\gclib\examples\cpp\x_programs.cpp
26  \Program Files (x86)\Galil\gclib\examples\cpp\x_simple.c
27  12 file(s) copied.
28  \Program Files (x86)\Galil\gclib\include\gclib.h
29  \Program Files (x86)\Galil\gclib\include\gclibo.h
30  \Program Files (x86)\Galil\gclib\include\gclib_errors.h
31  \Program Files (x86)\Galil\gclib\include\gclib_record.h
32  4 file(s) copied.
33  \Program Files (x86)\Galil\gclib\lib\dynamic\x86\gclib.lib
34  \Program Files (x86)\Galil\gclib\lib\dynamic\x86\gclibo.lib
35  2 file(s) copied.
36  \Program Files (x86)\Galil\gclib\dll\x86\gclib.dll
37  \Program Files (x86)\Galil\gclib\dll\x86\gclibo.dll
38  2 file(s) copied.
39 
40  C:\temp\borland>
41 
42 
43 ## Modify Path
44 
45 * Add Borland's compiler to the `PATH` variable.
46 
47 
48  C:\temp\borland>set PATH=c:\Program Files (x86)\Embarcadero\Studio\17.0\bin;%PATH%
49 
50 ## Convert lib files
51 
52  C:\temp\borland>move gclib.lib _gclib.lib
53  1 file(s) moved.
54 
55  C:\temp\borland>move gclibo.lib _gclibo.lib
56  1 file(s) moved.
57 
58  C:\temp\borland>coff2omf.exe _gclib.lib gclib.lib
59  COFF to OMF Converter Version 1.2.0 Copyright (c) 1999-2009 Embarcadero Technologies, Inc.
60  All rights reserved.
61 
62  C:\temp\borland>coff2omf.exe _gclibo.lib gclibo.lib
63  COFF to OMF Converter Version 1.2.0 Copyright (c) 1999-2009 Embarcadero Technologies, Inc.
64  All rights reserved.
65 
66 ## x_simple.c
67 
68 ### Edit GOpen() call as necessary
69 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.
70 
71 ### Compile
72 
73  C:\temp\borland>bcc32 gclib.lib gclibo.lib x_simple.c
74  Embarcadero C++ 7.10 for Win32 Copyright (c) 1993-2015 Embarcadero Technologies, Inc.
75  x_simple.c:
76  Turbo Incremental Link 6.72 Copyright (c) 1997-2015 Embarcadero Technologies, Inc.
77 
78 
79 ### Execute
80 
81  C:\temp\borland>x_simple.exe
82  version: 130.115.279
83  info: 192.168.0.43, DMC4143 Rev 1.2b, 9998
84  response: 61016.0000
85  :
86 
87 ## x_examples.cpp
88 
89 ### Review and Modify source
90 * 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.
91 * 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.
92 
93 ### Compile
94 
95 
96  C:\temp\borland>bcc32 -c *.cpp
97 
98 ### Link
99 
100  C:\temp\borland>bcc32 -o examples.exe *.obj gclib.lib gclibo.lib
101 
102 
103 ### Execute
104 
105  C:\temp\borland>examples.exe
106  Library version: 130.115.279
107 
108  192.168.0.43, DMC4020 Rev 1.2b, 291
109 
110 
111  ************************************************************************
112  Example GRead() and GWrite() usage
113  ************************************************************************
114 
115  Read 155 QR bytes.
116 
117  ************************************************************************
118  Example GCommand() usage
119  ************************************************************************
120  Revision report, ^R^V
121  DMC4020 Rev 1.2b
122  :
123 
124  Command Values
125  val is 10
126  val is 11
127  val is 3.1415
128  val is 9.869
129 
130  Command Trimming
131  > 95653016.0000
132  :<
133  > 95653016.0000<
134  >95653016.0000<
135 
136  Receiving Binary Data
137  QR read 155 bytes
138 
139  Error handling
140  QD correctly trapped, not allowed, try GArrayDownload()
141  DL correctly trapped, not allowed, try GProgramDownload()
142 
143  Modifying timeout
144  Burning program...OK
145 
146  ************************************************************************
147  Example GProgramDownload() and GProgramUpload() usage
148  ************************************************************************
149  GProgramDownload() correctly errored. Can't fit with level 3 compression
150  Program Downloaded with compression level 4
151  Uploading program:
152  #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
153  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
154 
155  Program executed as expected
156  ************************************************************************
157  Example GArrayDownload() and GArrayUpload() usage
158  ************************************************************************
159  2.0000, 4.0000, 6.0000, 8.0000, 10.0000, 12.0000, 14.0000, 16.0000, 18.000
160  0000
161 
162  2.0000, 1.0000, 3.0000, 5.0000, 10.0000, 12.0000, 14.0000, 16.0000, 18.000
163  0000
164 
165  3.0000, 5.0000, 10.0000
166 
167  ************************************************************************
168  Example GRecord() usage
169  ************************************************************************
170 
171  QR-based data record
172  38564
173  393216000
174 
175  DR-based data record
176  38670
177  38772
178  38874
179  38976
180  39078
181  39180
182  39282
183  39384
184  39486
185  39588
186  39690
187 
188  QR-based data record with offsets
189  39692
190  39692
191 
192  ************************************************************************
193  Example GMessage() usage
194  ************************************************************************
195  0.0000
196  1.0000
197  2.0000
198  3.0000
199  4.0000
200  5.0000
201  6.0000
202  7.0000
203  8.0000
204  9.0000
205 
206  ************************************************************************
207  Example GInterrupt() usage
208  ************************************************************************
209  "UI 8" executed.
210 
211  ************************************************************************
212  Example GMotionComplete() usage
213  ************************************************************************
214 
215  Position: 0, 0
216  Beginning independent motion... Motion Complete on A
217  Position: 8000, 0
218 
219  Position: 0, 0
220  Beginning vector motion... Motion Complete on vector plane S
221  Position: 6000, 0
222 
223 
224  examples.cpp executed OK
225  main() is finished. Press Enter to exit: