gclib  423
Communications API for Galil controllers and PLCs
mingw.md
1 # MinGW {#mingw}
2 
3 The following instructions were performed with x86 Minimalist GNU for Windows (MinGW) installed from http://mingw-w64.sourceforge.net/download.php#mingw-builds
4 
5 For brevity, these instructions assume the default installation location of "C:\Program Files (x86)\Galil\gclib".
6 
7 ## Copy Files
8 Copy "gclib\examples\mingw" to a convenient, writable location, e.g. "C:\temp". Run `C:\temp\mingw\copy_source.bat` to copy all files.
9 
10 ## x_simple.c
11 
12 ### Edit GOpen() call as necessary
13 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.
14 
15 ### Compile
16 
17 * Launch the MinGW terminal, e.g. *Start -> All Programs -> MinGW-W64 project -> i686-4.9.1-posix-dwarf-rt_v3-rev3 -> Run Terminal*.
18 * Navigate to the directory with the files above.
19 * Compile the code.
20 
21 
22  C:\temp\mingw>gcc x_simple.c -L. -lgclibo -lgclib -o simple.exe
23 
24 ### Execute
25 
26  C:\temp\mingw>simple.exe
27  rc: 0
28  version: 85.60.138
29  rc: 0
30  rc: 0
31  info: 10.1.3.17, DMC4020 Rev 1.2b, 291
32  rc: 0
33  response: 1584328.0000
34  :
35 
36 
37 ## x_examples.cpp
38 
39 ### Review and Modify source
40 * 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.
41 * 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.
42 
43 ### Compile
44 
45 * Launch the MinGW terminal, e.g. *Start -> All Programs -> MinGW-W64 project -> i686-4.9.1-posix-dwarf-rt_v3-rev3 -> Run Terminal*.
46 * Navigate to the directory with the files above.
47 * Compile the code.
48 
49 
50  C:\temp\mingw>g++ *.cpp -L. -lgclibo -lgclib -o examples.exe
51 
52 
53 ### Execute
54 
55  C:\temp\mingw>examples.exe
56  Library version: 41.35.34
57 
58  192.168.0.43, DMC4020 Rev 1.2b, 291
59 
60 
61  ************************************************************************
62  Example GRead() and GWrite() usage
63  ************************************************************************
64 
65  Read 155 QR bytes.
66 
67  ************************************************************************
68  Example GCommand() usage
69  ************************************************************************
70  Revision report, ^R^V
71  DMC4020 Rev 1.2b
72  :
73 
74  Command Values
75  val is 10
76  val is 11
77  val is 3.1415
78  val is 9.869
79 
80  Command Trimming
81  > 95653016.0000
82  :<
83  > 95653016.0000<
84  >95653016.0000<
85 
86  Receiving Binary Data
87  QR read 155 bytes
88 
89  Error handling
90  QD correctly trapped, not allowed, try GArrayDownload()
91  DL correctly trapped, not allowed, try GProgramDownload()
92 
93  Modifying timeout
94  Burning program...OK
95 
96  ************************************************************************
97  Example GProgramDownload() and GProgramUpload() usage
98  ************************************************************************
99  GProgramDownload() correctly errored. Can't fit with level 3 compression
100  Program Downloaded with compression level 4
101  Uploading program:
102  #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
103  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
104 
105  Program executed as expected
106  ************************************************************************
107  Example GArrayDownload() and GArrayUpload() usage
108  ************************************************************************
109  2.0000, 4.0000, 6.0000, 8.0000, 10.0000, 12.0000, 14.0000, 16.0000, 18.000
110  0000
111 
112  2.0000, 1.0000, 3.0000, 5.0000, 10.0000, 12.0000, 14.0000, 16.0000, 18.000
113  0000
114 
115  3.0000, 5.0000, 10.0000
116 
117  ************************************************************************
118  Example GRecord() usage
119  ************************************************************************
120 
121  QR-based data record
122  38564
123  393216000
124 
125  DR-based data record
126  38670
127  38772
128  38874
129  38976
130  39078
131  39180
132  39282
133  39384
134  39486
135  39588
136  39690
137 
138  QR-based data record with offsets
139  39692
140  39692
141 
142  ************************************************************************
143  Example GMessage() usage
144  ************************************************************************
145  0.0000
146  1.0000
147  2.0000
148  3.0000
149  4.0000
150  5.0000
151  6.0000
152  7.0000
153  8.0000
154  9.0000
155 
156  ************************************************************************
157  Example GInterrupt() usage
158  ************************************************************************
159  "UI 8" executed.
160 
161  ************************************************************************
162  Example GMotionComplete() usage
163  ************************************************************************
164 
165  Position: 0, 0
166  Beginning independent motion... Motion Complete on A
167  Position: 8000, 0
168 
169  Position: 0, 0
170  Beginning vector motion... Motion Complete on vector plane S
171  Position: 6000, 0
172 
173 
174  examples.cpp executed OK
175  main() is finished. Press Enter to exit: