|
@@ -62,12 +62,17 @@ public class SerialHelper {
|
62
|
62
|
short[] data = new short[1];
|
63
|
63
|
data[0] = OK;
|
64
|
64
|
if (!writeData(data)) {
|
65
|
|
- printErrorMessage("Timeout Probing for Cube");
|
|
65
|
+ printErrorMessage("Timeout sending probe for Cube");
|
66
|
66
|
return false;
|
67
|
67
|
}
|
68
|
68
|
data = readData(1);
|
69
|
69
|
if ((data == null) || (data[0] != OK)) {
|
70
|
70
|
printErrorMessage("No response from cube!");
|
|
71
|
+ if (data == null) {
|
|
72
|
+ System.out.println("Probe was null!");
|
|
73
|
+ } else {
|
|
74
|
+ System.out.println("Probe was " + data[0]);
|
|
75
|
+ }
|
71
|
76
|
return false;
|
72
|
77
|
}
|
73
|
78
|
return true;
|
|
@@ -85,26 +90,32 @@ public class SerialHelper {
|
85
|
90
|
// Send download command
|
86
|
91
|
tmp[0] = 'g';
|
87
|
92
|
if (!writeData(tmp)) {
|
88
|
|
- printErrorMessage("Timout Command");
|
|
93
|
+ printErrorMessage("Timout sending Command");
|
89
|
94
|
return null;
|
90
|
95
|
}
|
91
|
96
|
data = readData(1);
|
92
|
97
|
if ((data == null) || (data[0] != OK)) {
|
93
|
98
|
printErrorMessage("Response Error");
|
|
99
|
+ if (data == null) {
|
|
100
|
+ System.out.println("Download was null!");
|
|
101
|
+ } else {
|
|
102
|
+ System.out.println("Download was " + data[0]);
|
|
103
|
+ }
|
94
|
104
|
return null;
|
95
|
105
|
}
|
96
|
106
|
|
97
|
107
|
// Get animation count
|
98
|
108
|
data = readData(1);
|
99
|
109
|
if (data == null) {
|
100
|
|
- printErrorMessage("Response Error");
|
|
110
|
+ printErrorMessage("Response Error.");
|
|
111
|
+ System.out.println("Did not get animation count!");
|
101
|
112
|
return null;
|
102
|
113
|
} else {
|
103
|
114
|
animationCount = data[0];
|
104
|
115
|
}
|
105
|
116
|
tmp[0] = OK;
|
106
|
117
|
if (!writeData(tmp)) {
|
107
|
|
- printErrorMessage("Timout Response");
|
|
118
|
+ printErrorMessage("Timout acknowledging animation count!");
|
108
|
119
|
return null;
|
109
|
120
|
}
|
110
|
121
|
|
|
@@ -118,13 +129,14 @@ public class SerialHelper {
|
118
|
129
|
data = readData(1);
|
119
|
130
|
if (data == null) {
|
120
|
131
|
printErrorMessage("Response Error");
|
|
132
|
+ System.out.println("Did not get frame count!");
|
121
|
133
|
return null;
|
122
|
134
|
} else {
|
123
|
135
|
frameCount = data[0];
|
124
|
136
|
}
|
125
|
137
|
tmp[0] = OK;
|
126
|
138
|
if (!writeData(tmp)) {
|
127
|
|
- printErrorMessage("Timout Response");
|
|
139
|
+ printErrorMessage("Timout sending response Frame Count.");
|
128
|
140
|
return null;
|
129
|
141
|
}
|
130
|
142
|
|
|
@@ -136,13 +148,14 @@ public class SerialHelper {
|
136
|
148
|
data = readData(1);
|
137
|
149
|
if (data == null) {
|
138
|
150
|
printErrorMessage("Response Error");
|
|
151
|
+ System.out.println("Did not get frame duration!");
|
139
|
152
|
return null;
|
140
|
153
|
} else {
|
141
|
154
|
currentFrame.setTime(data[0]);
|
142
|
155
|
}
|
143
|
156
|
tmp[0] = OK;
|
144
|
157
|
if (!writeData(tmp)) {
|
145
|
|
- printErrorMessage("Timout Response");
|
|
158
|
+ printErrorMessage("Timout sending response Frame Duration");
|
146
|
159
|
return null;
|
147
|
160
|
}
|
148
|
161
|
|
|
@@ -150,13 +163,14 @@ public class SerialHelper {
|
150
|
163
|
data = readData(64);
|
151
|
164
|
if (data == null) {
|
152
|
165
|
printErrorMessage("Response Error");
|
|
166
|
+ System.out.println("Did not get frame data!");
|
153
|
167
|
return null;
|
154
|
168
|
} else {
|
155
|
169
|
currentFrame.setData(data);
|
156
|
170
|
}
|
157
|
171
|
tmp[0] = OK;
|
158
|
172
|
if (!writeData(tmp)) {
|
159
|
|
- printErrorMessage("Timout Response");
|
|
173
|
+ printErrorMessage("Timout sending response Frame Data");
|
160
|
174
|
return null;
|
161
|
175
|
}
|
162
|
176
|
|
|
@@ -182,24 +196,34 @@ public class SerialHelper {
|
182
|
196
|
// Send upload command
|
183
|
197
|
tmp[0] = 's';
|
184
|
198
|
if (!writeData(tmp)) {
|
185
|
|
- printErrorMessage("Timout Command");
|
|
199
|
+ printErrorMessage("Timout sending Command");
|
186
|
200
|
return -1;
|
187
|
201
|
}
|
188
|
202
|
data = readData(1);
|
189
|
203
|
if ((data == null) || (data[0] != OK)) {
|
190
|
|
- printErrorMessage("Response Error");
|
|
204
|
+ printErrorMessage("Response Error Command");
|
|
205
|
+ if (data == null) {
|
|
206
|
+ System.out.println("Response Command was null!");
|
|
207
|
+ } else {
|
|
208
|
+ System.out.println("Response Command was " + data[0]);
|
|
209
|
+ }
|
191
|
210
|
return -1;
|
192
|
211
|
}
|
193
|
212
|
|
194
|
213
|
// Send animation count
|
195
|
214
|
tmp[0] = (short)worker.size();
|
196
|
215
|
if (!writeData(tmp)) {
|
197
|
|
- printErrorMessage("Timeout numOfAnimations");
|
|
216
|
+ printErrorMessage("Timeout sending numOfAnimations");
|
198
|
217
|
return -1;
|
199
|
218
|
}
|
200
|
219
|
data = readData(1);
|
201
|
220
|
if ((data == null) || (data[0] != OK)) {
|
202
|
221
|
printErrorMessage("Response Error");
|
|
222
|
+ if (data == null) {
|
|
223
|
+ System.out.println("Response Count was null!");
|
|
224
|
+ } else {
|
|
225
|
+ System.out.println("Response Count was " + data[0]);
|
|
226
|
+ }
|
203
|
227
|
return -1;
|
204
|
228
|
}
|
205
|
229
|
|
|
@@ -208,12 +232,17 @@ public class SerialHelper {
|
208
|
232
|
// Send frame count
|
209
|
233
|
tmp[0] = (short)worker.getAnimation(a).size();
|
210
|
234
|
if (!writeData(tmp)) {
|
211
|
|
- printErrorMessage("Timeout numOfFrames");
|
|
235
|
+ printErrorMessage("Timeout sending numOfFrames");
|
212
|
236
|
return -1;
|
213
|
237
|
}
|
214
|
238
|
data = readData(1);
|
215
|
239
|
if ((data == null) || (data[0] != OK)) {
|
216
|
240
|
printErrorMessage("Response Error");
|
|
241
|
+ if (data == null) {
|
|
242
|
+ System.out.println("Frame Count was null!");
|
|
243
|
+ } else {
|
|
244
|
+ System.out.println("Frame Count was " + data[0]);
|
|
245
|
+ }
|
217
|
246
|
return -1;
|
218
|
247
|
}
|
219
|
248
|
|
|
@@ -222,23 +251,33 @@ public class SerialHelper {
|
222
|
251
|
// Frame duration
|
223
|
252
|
tmp[0] = worker.getAnimation(a).getFrame(f).getTime();
|
224
|
253
|
if (!writeData(tmp)) {
|
225
|
|
- printErrorMessage("Timeout Frame duration");
|
|
254
|
+ printErrorMessage("Timeout sending Frame duration");
|
226
|
255
|
return -1;
|
227
|
256
|
}
|
228
|
257
|
data = readData(1);
|
229
|
258
|
if ((data == null) || (data[0] != OK)) {
|
230
|
259
|
printErrorMessage("Response Error");
|
|
260
|
+ if (data == null) {
|
|
261
|
+ System.out.println("Duration was null!");
|
|
262
|
+ } else {
|
|
263
|
+ System.out.println("Duration was " + data[0]);
|
|
264
|
+ }
|
231
|
265
|
return -1;
|
232
|
266
|
}
|
233
|
267
|
|
234
|
268
|
// Frame data
|
235
|
269
|
if (!writeData(worker.getAnimation(a).getFrame(f).getData())) {
|
236
|
|
- printErrorMessage("Timeout Frame");
|
|
270
|
+ printErrorMessage("Timeout sending Frame");
|
237
|
271
|
return -1;
|
238
|
272
|
}
|
239
|
273
|
data = readData(1);
|
240
|
274
|
if ((data == null) || (data[0] != OK)) {
|
241
|
275
|
printErrorMessage("Response Error");
|
|
276
|
+ if (data == null) {
|
|
277
|
+ System.out.println("Datawas null!");
|
|
278
|
+ } else {
|
|
279
|
+ System.out.println("Data was " + data[0]);
|
|
280
|
+ }
|
242
|
281
|
return -1;
|
243
|
282
|
}
|
244
|
283
|
}
|
|
@@ -251,12 +290,17 @@ public class SerialHelper {
|
251
|
290
|
tmp[2] = OK;
|
252
|
291
|
tmp[3] = OK;
|
253
|
292
|
if (!writeData(tmp)) {
|
254
|
|
- printErrorMessage("Timeout Finish");
|
|
293
|
+ printErrorMessage("Timeout sending Finish");
|
255
|
294
|
return -1;
|
256
|
295
|
}
|
257
|
296
|
data = readData(1);
|
258
|
297
|
if ((data == null) || (data[0] != OK)) {
|
259
|
298
|
printErrorMessage("Response Error");
|
|
299
|
+ if (data == null) {
|
|
300
|
+ System.out.println("Finish was null!");
|
|
301
|
+ } else {
|
|
302
|
+ System.out.println("Finish was " + data[0]);
|
|
303
|
+ }
|
260
|
304
|
return -1;
|
261
|
305
|
}
|
262
|
306
|
return 0;
|