@@ -111,12 +111,16 @@ void preExecute() {
111111 //playerN.start();
112112
113113 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+ }
120124 if (repeat || buttonText .length () == 0 ) button .setText ("Stop" );
121125 else {
122126 if (Character .isUpperCase (strLastChar .charAt (0 ))) button .setText (buttonText1 + "ING" );
@@ -188,24 +192,27 @@ protected String doInBackground(Void... a) {
188192 Cs108Connector .Rx000pkgData rx000pkgData = MainActivity .mCs108Library4a .onRFIDEvent ();
189193 if (MainActivity .mCs108Library4a .mrfidToWriteSize () != 0 ) timeMillis = System .currentTimeMillis ();
190194 else if (rx000pkgData != null ) {
195+ //MainActivity.mCs108Library4a.appendToLog("rx000pkgData.responseType = " + rx000pkgData.responseType.toString());
191196 if (rx000pkgData .responseType == null ) {
192197 publishProgress ("null response" );
193198 } else if (rx000pkgData .responseType == Cs108Connector .HostCmdResponseTypes .TYPE_18K6C_TAG_ACCESS ) {
194199 if (true ) {
195200 if (rx000pkgData .decodedError == null ) {
196201 if (done == false ) {
197202 accessResult = rx000pkgData .decodedResult ;
198- MainActivity .mCs108Library4a .appendToLog ("StreamOut, accResult=" + accessResult );
203+ // MainActivity.mCs108Library4a.appendToLog("StreamOut, accResult=" + accessResult);
199204 if (updateRunnable != null ) {
200- MainActivity .mCs108Library4a .appendToLog ("StreamOut: start updateRunnable" );
205+ // MainActivity.mCs108Library4a.appendToLog("StreamOut: start updateRunnable");
201206 mHandler .post (updateRunnable );
202207 }
203208 }
204209 done = true ;
205210 publishProgress (null , rx000pkgData .decodedResult );
211+ } else {
212+ //MainActivity.mCs108Library4a.appendToLog("decodeError = " + rx000pkgData.decodedError + ", length = " + rx000pkgData.decodedError.length());
213+ publishProgress (rx000pkgData .decodedError );
206214 }
207- else publishProgress (rx000pkgData .decodedError );
208- iTimeOut = 500 ;
215+ iTimeOut = 1000 ;
209216 }
210217 } else if (rx000pkgData .responseType == Cs108Connector .HostCmdResponseTypes .TYPE_COMMAND_END ) {
211218 if (rx000pkgData .decodedError != null ) { endingMessaage = rx000pkgData .decodedError ; ending = true ; }
@@ -224,17 +231,16 @@ else if (repeat && (nextNew == false || resultError.length() != 0)) {
224231 timeMillis = System .currentTimeMillis ();
225232 }
226233 else if (notificationData != null ) {
227- MainActivity .mCs108Library4a .appendToLog ("resultError=" + MainActivity .mCs108Library4a .byteArrayToString (notificationData ));
234+ // MainActivity.mCs108Library4a.appendToLog("resultError=" + MainActivity.mCs108Library4a.byteArrayToString(notificationData));
228235 publishProgress ("Received notification uplink event 0xA101 with error code=" + MainActivity .mCs108Library4a .byteArrayToString (notificationData ));
229- timeMillis = System .currentTimeMillis ();
230- iTimeOut = 500 ;
236+ taskCancelReason = TaskCancelRReason .TIMEOUT ;
231237 }
232238 if (System .currentTimeMillis () - timeMillis > iTimeOut ) {
233- MainActivity .mCs108Library4a .appendToLog ("endingMessage: iTimeout = " + iTimeOut );
239+ // MainActivity.mCs108Library4a.appendToLog("endingMessage: iTimeout = " + iTimeOut);
234240 taskCancelReason = TaskCancelRReason .TIMEOUT ;
235241 }
236242 if (taskCancelReason != TaskCancelRReason .NULL ) {
237- MainActivity .mCs108Library4a .appendToLog ("taskCancelReason=" + TaskCancelRReason .values ());
243+ // MainActivity.mCs108Library4a.appendToLog("taskCancelReason=" + TaskCancelRReason.values());
238244 cancel (true );
239245 }
240246 }
@@ -248,6 +254,7 @@ else if (notificationData != null) {
248254 protected void onProgressUpdate (String ... output ) {
249255 if (true ) progressUpdate (output );
250256 else if (output [0 ] != null ) {
257+ MainActivity .mCs108Library4a .appendToLog ("onProgressUpdate output[0] = " + output [0 ]);
251258 if (output [0 ].length () == 2 ) {
252259 if (output [0 ].contains ("TT" )) {
253260 gotInventory = true ;
@@ -275,6 +282,7 @@ else if (output[0] != null) {
275282 taskCancelReason = TaskCancelRReason .ERROR ;
276283 }
277284 } else {
285+ MainActivity .mCs108Library4a .appendToLog ("onProgressUpdate output[1] = " + output [1 ]);
278286 if (registerYield != null ) {
279287 if (tagInventoried != null ) {
280288 tagList .add (tagInventoried );
@@ -305,6 +313,7 @@ protected void onPostExecute(String result) {
305313
306314 protected void progressUpdate (String ... output ) {
307315 if (output [0 ] != null ) {
316+ MainActivity .mCs108Library4a .appendToLog ("onProgressUpdate output[0] = " + output [0 ]);
308317 if (output [0 ].length () == 2 ) {
309318 if (output [0 ].contains ("TT" )) {
310319 gotInventory = true ;
@@ -331,6 +340,7 @@ protected void progressUpdate(String... output) {
331340 MainActivity .mCs108Library4a .appendToLog ("output[0]: " + output [0 ] + ", resultError = " + resultError );
332341 }
333342 } else {
343+ MainActivity .mCs108Library4a .appendToLog ("onProgressUpdate output[1] = " + output [1 ]);
334344 if (registerYield != null ) {
335345 if (tagInventoried != null ) {
336346 tagList .add (tagInventoried );
@@ -359,6 +369,9 @@ void DeviceConnectTask4RegisterEnding() {
359369 strErrorMessage = "" ;
360370 switch (taskCancelReason ) {
361371 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 );
362375 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" );
363376 //else Toast.makeText(MainActivity.mContext, R.string.toast_abort_by_SUCCESS, Toast.LENGTH_SHORT).show();
364377 break ;
0 commit comments