Beispiel #1
0
            public static void run()
            {
                byte[]           Data = new byte[8];
                byte[]           tmpData;
                mHandler         hand = new mHandler();
                Ibutton_Activity obj  = new Ibutton_Activity();


                while (stopflag)
                {
                    Message msg = hand.ObtainMessage();
                    tmpData = obj.aclasHdqApi.Read();

                    if (ArrayZero(tmpData))
                    {
                        // Log.d(TAG, "no data");
                        msg.Arg1 = 1;
                    }
                    else
                    {
                        msg.Arg2 = 0;
                    }
                    if (ArrayCmp(tmpData, Data))
                    {
                        //Log.d(TAG, "the same  data continue");
                        try
                        {
                            Thread.Sleep(500);
                        }
                        catch (ThreadInterruptedException e)
                        {
                            // TODO Auto-generated catch block
                            //e.printStackTrace();
                            Console.WriteLine(e.ToString().ToCharArray());
                        }
                        continue;
                    }
                    else
                    {
                        System.Array.Copy(tmpData, 0, Data, 0, 8);
                        obj.cardNo = ByteArrayToString(Data);
                    }
                    hand.SendMessage(msg);

                    // Log.d(TAG, "Hdq -------> Thread");
                    try
                    {
                        //  sleep(500); //200ms
                        Thread.Sleep(500);
                    }
                    catch (ThreadInterruptedException e)
                    {
                        // TODO Auto-generated catch block
                        // e.printStackTrace();
                        Console.WriteLine(e.ToString().ToCharArray());
                    }

                    if (!stopflag)
                    {
                        break;
                    }
                }
            }