@@ -111,12 +111,16 @@ void preExecute() {
111
111
//playerN.start();
112
112
113
113
buttonText = button .getText ().toString ().trim ();
114
- String buttonText1 = null ; String strLastChar = buttonText .substring (buttonText .length ()-1 );
115
- if (strLastChar .toUpperCase ().matches ("E" )) {
116
- buttonText1 = buttonText .substring (0 , buttonText .length ()-1 );
117
- } else if (buttonText .toUpperCase ().matches ("STOP" )) {
118
- buttonText1 = buttonText ; buttonText1 += buttonText1 .substring (buttonText .length ()-1 );
119
- } else buttonText1 = buttonText ;
114
+ String buttonText1 = "" ; String strLastChar = "" ;
115
+ if (buttonText .length () != 0 ) {
116
+ strLastChar = buttonText .substring (buttonText .length () - 1 );
117
+ if (strLastChar .toUpperCase ().matches ("E" )) {
118
+ buttonText1 = buttonText .substring (0 , buttonText .length () - 1 );
119
+ } else if (buttonText .toUpperCase ().matches ("STOP" )) {
120
+ buttonText1 = buttonText ;
121
+ buttonText1 += buttonText1 .substring (buttonText .length () - 1 );
122
+ } else buttonText1 = buttonText ;
123
+ }
120
124
if (repeat || buttonText .length () == 0 ) button .setText ("Stop" );
121
125
else {
122
126
if (Character .isUpperCase (strLastChar .charAt (0 ))) button .setText (buttonText1 + "ING" );
@@ -188,24 +192,27 @@ protected String doInBackground(Void... a) {
188
192
Cs108Connector .Rx000pkgData rx000pkgData = MainActivity .mCs108Library4a .onRFIDEvent ();
189
193
if (MainActivity .mCs108Library4a .mrfidToWriteSize () != 0 ) timeMillis = System .currentTimeMillis ();
190
194
else if (rx000pkgData != null ) {
195
+ //MainActivity.mCs108Library4a.appendToLog("rx000pkgData.responseType = " + rx000pkgData.responseType.toString());
191
196
if (rx000pkgData .responseType == null ) {
192
197
publishProgress ("null response" );
193
198
} else if (rx000pkgData .responseType == Cs108Connector .HostCmdResponseTypes .TYPE_18K6C_TAG_ACCESS ) {
194
199
if (true ) {
195
200
if (rx000pkgData .decodedError == null ) {
196
201
if (done == false ) {
197
202
accessResult = rx000pkgData .decodedResult ;
198
- MainActivity .mCs108Library4a .appendToLog ("StreamOut, accResult=" + accessResult );
203
+ // MainActivity.mCs108Library4a.appendToLog("StreamOut, accResult=" + accessResult);
199
204
if (updateRunnable != null ) {
200
- MainActivity .mCs108Library4a .appendToLog ("StreamOut: start updateRunnable" );
205
+ // MainActivity.mCs108Library4a.appendToLog("StreamOut: start updateRunnable");
201
206
mHandler .post (updateRunnable );
202
207
}
203
208
}
204
209
done = true ;
205
210
publishProgress (null , rx000pkgData .decodedResult );
211
+ } else {
212
+ //MainActivity.mCs108Library4a.appendToLog("decodeError = " + rx000pkgData.decodedError + ", length = " + rx000pkgData.decodedError.length());
213
+ publishProgress (rx000pkgData .decodedError );
206
214
}
207
- else publishProgress (rx000pkgData .decodedError );
208
- iTimeOut = 500 ;
215
+ iTimeOut = 1000 ;
209
216
}
210
217
} else if (rx000pkgData .responseType == Cs108Connector .HostCmdResponseTypes .TYPE_COMMAND_END ) {
211
218
if (rx000pkgData .decodedError != null ) { endingMessaage = rx000pkgData .decodedError ; ending = true ; }
@@ -224,17 +231,16 @@ else if (repeat && (nextNew == false || resultError.length() != 0)) {
224
231
timeMillis = System .currentTimeMillis ();
225
232
}
226
233
else if (notificationData != null ) {
227
- MainActivity .mCs108Library4a .appendToLog ("resultError=" + MainActivity .mCs108Library4a .byteArrayToString (notificationData ));
234
+ // MainActivity.mCs108Library4a.appendToLog("resultError=" + MainActivity.mCs108Library4a.byteArrayToString(notificationData));
228
235
publishProgress ("Received notification uplink event 0xA101 with error code=" + MainActivity .mCs108Library4a .byteArrayToString (notificationData ));
229
- timeMillis = System .currentTimeMillis ();
230
- iTimeOut = 500 ;
236
+ taskCancelReason = TaskCancelRReason .TIMEOUT ;
231
237
}
232
238
if (System .currentTimeMillis () - timeMillis > iTimeOut ) {
233
- MainActivity .mCs108Library4a .appendToLog ("endingMessage: iTimeout = " + iTimeOut );
239
+ // MainActivity.mCs108Library4a.appendToLog("endingMessage: iTimeout = " + iTimeOut);
234
240
taskCancelReason = TaskCancelRReason .TIMEOUT ;
235
241
}
236
242
if (taskCancelReason != TaskCancelRReason .NULL ) {
237
- MainActivity .mCs108Library4a .appendToLog ("taskCancelReason=" + TaskCancelRReason .values ());
243
+ // MainActivity.mCs108Library4a.appendToLog("taskCancelReason=" + TaskCancelRReason.values());
238
244
cancel (true );
239
245
}
240
246
}
@@ -248,6 +254,7 @@ else if (notificationData != null) {
248
254
protected void onProgressUpdate (String ... output ) {
249
255
if (true ) progressUpdate (output );
250
256
else if (output [0 ] != null ) {
257
+ MainActivity .mCs108Library4a .appendToLog ("onProgressUpdate output[0] = " + output [0 ]);
251
258
if (output [0 ].length () == 2 ) {
252
259
if (output [0 ].contains ("TT" )) {
253
260
gotInventory = true ;
@@ -275,6 +282,7 @@ else if (output[0] != null) {
275
282
taskCancelReason = TaskCancelRReason .ERROR ;
276
283
}
277
284
} else {
285
+ MainActivity .mCs108Library4a .appendToLog ("onProgressUpdate output[1] = " + output [1 ]);
278
286
if (registerYield != null ) {
279
287
if (tagInventoried != null ) {
280
288
tagList .add (tagInventoried );
@@ -305,6 +313,7 @@ protected void onPostExecute(String result) {
305
313
306
314
protected void progressUpdate (String ... output ) {
307
315
if (output [0 ] != null ) {
316
+ MainActivity .mCs108Library4a .appendToLog ("onProgressUpdate output[0] = " + output [0 ]);
308
317
if (output [0 ].length () == 2 ) {
309
318
if (output [0 ].contains ("TT" )) {
310
319
gotInventory = true ;
@@ -331,6 +340,7 @@ protected void progressUpdate(String... output) {
331
340
MainActivity .mCs108Library4a .appendToLog ("output[0]: " + output [0 ] + ", resultError = " + resultError );
332
341
}
333
342
} else {
343
+ MainActivity .mCs108Library4a .appendToLog ("onProgressUpdate output[1] = " + output [1 ]);
334
344
if (registerYield != null ) {
335
345
if (tagInventoried != null ) {
336
346
tagList .add (tagInventoried );
@@ -359,6 +369,9 @@ void DeviceConnectTask4RegisterEnding() {
359
369
strErrorMessage = "" ;
360
370
switch (taskCancelReason ) {
361
371
case NULL :
372
+ if (accessResult == null ) MainActivity .mCs108Library4a .appendToLog ("taskCancelReason: NULL accessResult" );
373
+ if (resultError != null ) MainActivity .mCs108Library4a .appendToLog ("taskCancelReason: resultError = " + resultError );
374
+ if (endingMessaage != null ) MainActivity .mCs108Library4a .appendToLog ("taskCancelReason: endingMessaage = " + endingMessaage );
362
375
if (accessResult == null || (resultError != null && resultError .length () != 0 ) || (endingMessaage != null && endingMessaage .length () != 0 )) strErrorMessage += ("Finish as COMMAND END is received " + (gotInventory ? "WITH" : "WITHOUT" ) + " tag response" );
363
376
//else Toast.makeText(MainActivity.mContext, R.string.toast_abort_by_SUCCESS, Toast.LENGTH_SHORT).show();
364
377
break ;
0 commit comments