要使用NeuroSky的MindWave來抓一些腦波資料,他提供的Android API利用handler回傳message來回傳mindwave所抓到的腦波訊息。

在使用上我需要將EEG訊號儲存在Sqlite中,因為raw data的偵測與傳送速率是512 Hz,且官方所給的範例使用的handler是UI thread handler。自己寫的程式使用此handler來儲存資料會使得UI thread產生ANR的問題。

因此想先將偵測到的message儲存在一個容器內,然後呼叫另一個thread批次的儲存在Sqlite中。

然後慘劇就發生了,不曉得為什麼容器內的message會被當作垃圾回收!

handler程式碼如下:

    @Override
    public void handleMessage(Message msg) {
        switch (msg.what) {
            case 0:
                Log.i(TAG, "got Message 0");
                break;
            case TGDevice.MSG_STATE_CHANGE:
                switch (msg.arg1) {
                    case TGDevice.STATE_IDLE:
                        break;
                    case TGDevice.STATE_CONNECTING:
                        SensingActivity.setState("Connecting...");
                        break;
                    case TGDevice.STATE_CONNECTED:
                        SensingActivity.setState("Connected.");
                        SensingActivity.getTGDevice().start();
                        break;
                    case TGDevice.STATE_NOT_FOUND:
                        SensingActivity.setState("Can't find");
                        break;
                    case TGDevice.STATE_NOT_PAIRED:
                        SensingActivity.setState("not paired");
                        break;
                    case TGDevice.STATE_DISCONNECTED:
                        SensingActivity.setState("Disconnected mang");
                }
                break;
            case TGDevice.MSG_POOR_SIGNAL:
                //signal = msg.arg1;
                SensingActivity.setState("Poor Signal: " + String.valueOf(msg.arg1));
                break;
            case TGDevice.MSG_RAW_DATA:
                //msgBuffer.add(msg);
                msgBuffer[index] = msg;
                Log.e(TAG, "In: msg.what = " + msgBuffer[index].what + ", msg.when = " + msgBuffer[index].getWhen() + ", number = " + index);
                index++;
                break;
            case TGDevice.MSG_HEART_RATE:
                break;
            case TGDevice.MSG_ATTENTION:
                //msgBuffer.add(msg);
                //msgBuffer[index++] = msg;
                msgBuffer[index] = msg;
                Log.e(TAG, "In: msg.what = " + msgBuffer[index].what + ", msg.when = " + msgBuffer[index].getWhen() + ", number = " + index);
                index++;
                SensingActivity.setAtt(String.valueOf(msg.arg1));
                SensingActivity.setp1(msg.arg1);
            case TGDevice.MSG_MEDITATION:
                //msgBuffer.add(msg);
               // msgBuffer[index++] = msg;
                msgBuffer[index] = msg;
                Log.e(TAG, "In: msg.what = " + msgBuffer[index].what + ", msg.when = " + msgBuffer[index].getWhen() + ", number = " + index);
                index++;
                SensingActivity.setMed(String.valueOf(msg.arg1));
                SensingActivity.setp2(msg.arg1);
                break;
            case TGDevice.MSG_BLINK:
                msgBuffer[index] = msg;
                Log.e(TAG, "In: msg.what = " + msgBuffer[index].what + ", msg.when = " + msgBuffer[index].getWhen() + ", number = " + index);
                index++;
                break;
            case TGDevice.MSG_RAW_COUNT:
                //tv.append("Raw Count: " + msg.arg1 + "\n");
                break;
            case TGDevice.MSG_LOW_BATTERY:
                //Toast.makeText(getApplicationContext(), "Low battery!", Toast.LENGTH_SHORT).show();
                break;
            case TGDevice.MSG_RAW_MULTI:
                //TGRawMulti rawM = (TGRawMulti)msg.obj;
                //tv.append("Raw1: " + rawM.ch1 + "\nRaw2: " + rawM.ch2);
            default:
                break;
        }

        //if (msgBuffer.size() > maxBufferSize - 1) {
        if (index >= maxBufferSize) {
            index = 0;
            //Fixme
//            int i = 0;
//            for(Message mm : msgBuffer) {
//                Log.d(TAG, "check message msg.what = " + mm.what + " number = " + i);
//                i++;
//            }
            for (int i = 0; i<maxBufferSize; ++i) {
                Log.d(TAG, "Out: msg.what = " + msgBuffer[i].what + ", msg.when = " + msgBuffer[i].getWhen() + ", number = " + i);
            }
            // 儲存db資料
            if (OneOrTwo == 1) {
//                t1 = new SavingData(Buffer1);
//                while (t2 != null && t2.myThread.isAlive()) ;
                //Buffer2 = Collections.synchronizedList(new ArrayList<Message>());
                Buffer2 = new Message[maxBufferSize];
                msgBuffer = Buffer2;
                OneOrTwo = 2;
            } else {
//                t2 = new SavingData(Buffer2);
//                while (t1.myThread.isAlive()) ;
                //Buffer1 = Collections.synchronizedList(new ArrayList<Message>());
                Buffer1 = new Message[maxBufferSize];
                msgBuffer = Buffer1;
                OneOrTwo = 1;
            }
        }

    }

在第34~36行,我們將message存放到Array中,然後馬上將Array的內容印出來檢查

當Array的內容儲存到一定的數量,我們再將Array所有的內容印出來再次檢查,如第84~86。Log的結果卻發現在84~86的傾印的內容有一大堆的message變成空值,這個問題抓了很久一直找不到解決的方法,是哪一個細節忽略掉了呢? 做成紀錄先

EventLog如下,line 1 ~ 100是存入容器時的log,line 101 ~ 200是批次列印時的結果。發現在批次列印時,容器內的message物件都不是原來的物件了(從msg.when推測出來)

01-26 15:16:10.340 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376205, number = 0
01-26 15:16:10.340 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376205, number = 1
01-26 15:16:10.350 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376219, number = 2
01-26 15:16:10.350 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376219, number = 3
01-26 15:16:10.350 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376220, number = 4
01-26 15:16:10.350 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376220, number = 5
01-26 15:16:10.350 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376221, number = 6
01-26 15:16:10.350 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376221, number = 7
01-26 15:16:10.350 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376221, number = 8
01-26 15:16:10.350 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376221, number = 9
01-26 15:16:10.350 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376222, number = 10
01-26 15:16:10.350 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376222, number = 11
01-26 15:16:10.360 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376237, number = 12
01-26 15:16:10.360 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376237, number = 13
01-26 15:16:10.360 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376237, number = 14
01-26 15:16:10.360 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376238, number = 15
01-26 15:16:10.360 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376238, number = 16
01-26 15:16:10.360 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376238, number = 17
01-26 15:16:10.360 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376238, number = 18
01-26 15:16:10.370 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376238, number = 19
01-26 15:16:10.370 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376239, number = 20
01-26 15:16:10.370 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376239, number = 21
01-26 15:16:10.380 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376257, number = 22
01-26 15:16:10.380 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376257, number = 23
01-26 15:16:10.380 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376258, number = 24
01-26 15:16:10.380 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376259, number = 25
01-26 15:16:10.380 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376259, number = 26
01-26 15:16:10.390 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376260, number = 27
01-26 15:16:10.390 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376260, number = 28
01-26 15:16:10.390 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376261, number = 29
01-26 15:16:10.390 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376261, number = 30
01-26 15:16:10.390 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376261, number = 31
01-26 15:16:10.400 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376277, number = 32
01-26 15:16:10.400 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376277, number = 33
01-26 15:16:10.400 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376277, number = 34
01-26 15:16:10.400 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376278, number = 35
01-26 15:16:10.400 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376278, number = 36
01-26 15:16:10.400 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376278, number = 37
01-26 15:16:10.400 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376279, number = 38
01-26 15:16:10.400 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376279, number = 39
01-26 15:16:10.400 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376279, number = 40
01-26 15:16:10.400 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376279, number = 41
01-26 15:16:10.420 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376297, number = 42
01-26 15:16:10.420 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376297, number = 43
01-26 15:16:10.420 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376297, number = 44
01-26 15:16:10.420 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376297, number = 45
01-26 15:16:10.420 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376298, number = 46
01-26 15:16:10.420 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376298, number = 47
01-26 15:16:10.420 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376298, number = 48
01-26 15:16:10.430 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376298, number = 49
01-26 15:16:10.430 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376298, number = 50
01-26 15:16:10.430 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376298, number = 51
01-26 15:16:10.440 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376314, number = 52
01-26 15:16:10.440 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376315, number = 53
01-26 15:16:10.440 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376315, number = 54
01-26 15:16:10.440 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376316, number = 55
01-26 15:16:10.440 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376316, number = 56
01-26 15:16:10.440 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376317, number = 57
01-26 15:16:10.440 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376317, number = 58
01-26 15:16:10.440 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376318, number = 59
01-26 15:16:10.440 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376318, number = 60
01-26 15:16:10.440 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376319, number = 61
01-26 15:16:10.460 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376337, number = 62
01-26 15:16:10.460 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376337, number = 63
01-26 15:16:10.460 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376338, number = 64
01-26 15:16:10.460 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376338, number = 65
01-26 15:16:10.460 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376339, number = 66
01-26 15:16:10.470 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376340, number = 67
01-26 15:16:10.470 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376341, number = 68
01-26 15:16:10.470 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376341, number = 69
01-26 15:16:10.470 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376342, number = 70
01-26 15:16:10.470 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376342, number = 71
01-26 15:16:10.480 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376354, number = 72
01-26 15:16:10.480 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376355, number = 73
01-26 15:16:10.480 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376355, number = 74
01-26 15:16:10.480 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376356, number = 75
01-26 15:16:10.480 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376356, number = 76
01-26 15:16:10.480 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376356, number = 77
01-26 15:16:10.480 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376356, number = 78
01-26 15:16:10.480 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376357, number = 79
01-26 15:16:10.480 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376357, number = 80
01-26 15:16:10.480 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376357, number = 81
01-26 15:16:10.510 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376375, number = 82
01-26 15:16:10.510 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376376, number = 83
01-26 15:16:10.510 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376376, number = 84
01-26 15:16:10.510 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376377, number = 85
01-26 15:16:10.510 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376377, number = 86
01-26 15:16:10.510 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376377, number = 87
01-26 15:16:10.510 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376377, number = 88
01-26 15:16:10.510 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376377, number = 89
01-26 15:16:10.510 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376378, number = 90
01-26 15:16:10.510 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376378, number = 91
01-26 15:16:10.520 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376395, number = 92
01-26 15:16:10.520 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376395, number = 93
01-26 15:16:10.520 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376396, number = 94
01-26 15:16:10.520 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376396, number = 95
01-26 15:16:10.520 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376396, number = 96
01-26 15:16:10.520 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376396, number = 97
01-26 15:16:10.520 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376396, number = 98
01-26 15:16:10.520 31127-31127/cycu.nclab.demo.neuroeeg E/TGDeviceHandler: In: msg.what = 128, msg.when = 1129376396, number = 99
01-26 15:16:10.520 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 0
01-26 15:16:10.520 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 1
01-26 15:16:10.520 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 2
01-26 15:16:10.520 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 3
01-26 15:16:10.520 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 4
01-26 15:16:10.520 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 5
01-26 15:16:10.520 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 6
01-26 15:16:10.520 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376396, number = 7
01-26 15:16:10.520 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 8
01-26 15:16:10.520 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 9
01-26 15:16:10.520 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 10
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 11
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 12
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 13
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 14
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 15
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 16
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 17
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376396, number = 18
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 19
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 20
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 21
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 22
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 23
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 24
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 25
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 26
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 27
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 28
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 29
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376396, number = 30
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 31
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 32
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376396, number = 33
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 34
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 35
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 36
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 37
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 38
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 39
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 40
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 41
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 42
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376396, number = 43
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 44
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 45
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 46
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 47
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 48
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 49
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 50
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 51
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 52
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 53
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 54
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 55
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 56
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 57
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 58
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 59
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 60
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 61
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 62
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 63
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 64
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 65
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 66
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 67
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 68
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 69
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 70
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 71
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 72
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 73
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 74
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 75
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 76
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 77
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 78
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 79
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 80
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 81
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 82
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 83
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 84
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 85
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 86
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 87
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 88
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376396, number = 89
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 90
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 91
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 92
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 93
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 94
01-26 15:16:10.530 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 95
01-26 15:16:10.540 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 96
01-26 15:16:10.540 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 0, msg.when = 0, number = 97
01-26 15:16:10.540 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376397, number = 98
01-26 15:16:10.540 31127-31127/cycu.nclab.demo.neuroeeg D/TGDeviceHandler: Out: msg.what = 128, msg.when = 1129376396, number = 99

[補充]

如果改成每收到一個message就發動一個thread去做存檔的工作,一樣會發生message物件不見得問題,覺得是我忽略了某一個基礎的問題,唉~

@Override
public void handleMessage(Message msg) {
    switch (msg.what) {
        ...
        case TGDevice.MSG_RAW_DATA:
            Log.e(TAG, "In: msg.what = " + msg.what + ", msg.when = " + msg.getWhen() + ", msgCount = " + msgCount++);
            new SavingData2(msg);
            break;
        case TGDevice.MSG_ATTENTION:
            Log.e(TAG, "In: msg.what = " + msg.what + ", msg.when = " + msg.getWhen() + ", msgCount = " + msgCount++);
            new SavingData2(msg);
            SensingActivity.setAtt(String.valueOf(msg.arg1));
            SensingActivity.setp1(msg.arg1);
        case TGDevice.MSG_MEDITATION:
            Log.e(TAG, "In: msg.what = " + msg.what + ", msg.when = " + msg.getWhen() + ", msgCount = " + msgCount++);
            new SavingData2(msg);
            SensingActivity.setMed(String.valueOf(msg.arg1));
            SensingActivity.setp2(msg.arg1);
            break;
        case TGDevice.MSG_BLINK:
            Log.e(TAG, "In: msg.what = " + msg.what + ", msg.when = " + msg.getWhen() + ", msgCount = " + msgCount++);
            new SavingData2(msg);
            break;
        ...
        default:
            break;
    }
}

另外改成每收到一個message就發動一個thread去做存檔,因為thread會自己排程很難去控制他的順序,所以又會有後產生的message先存檔的問題,造成資料庫中的資料順序不對,可以看下面的log節錄,TGDeviceHandler產生的順序和SavingData Thread執行的順序。

01-26 16:19:23.870 30164-30164/cycu.nclab.demo.neuroeeg E/TGDeviceHandler2: In: msg.what = 128, msg.when = 1133169728, msgCount = 7216
01-26 16:19:23.870 30164-30164/cycu.nclab.demo.neuroeeg E/TGDeviceHandler2: In: msg.what = 128, msg.when = 1133169728, msgCount = 7217
01-26 16:19:23.870 30164-30164/cycu.nclab.demo.neuroeeg E/TGDeviceHandler2: In: msg.what = 128, msg.when = 1133169728, msgCount = 7218
01-26 16:19:23.870 30164-30164/cycu.nclab.demo.neuroeeg E/TGDeviceHandler2: In: msg.what = 128, msg.when = 1133169744, msgCount = 7219
01-26 16:19:23.870 30164-6424/cycu.nclab.demo.neuroeeg I/SavingData2: Out: msg.what = 0, msg.when = 0, msgCount = 7216
01-26 16:19:23.870 30164-6424/cycu.nclab.demo.neuroeeg E/DB_neurosky: saving error on msg.what = 0
01-26 16:19:23.870 30164-6423/cycu.nclab.demo.neuroeeg I/SavingData2: Out: msg.what = 128, msg.when = 1133169746, msgCount = 7215
01-26 16:19:23.870 30164-6422/cycu.nclab.demo.neuroeeg I/SavingData2: Out: msg.what = 128, msg.when = 1133169745, msgCount = 7214
01-26 16:19:23.870 30164-6425/cycu.nclab.demo.neuroeeg I/SavingData2: Out: msg.what = 0, msg.when = 0, msgCount = 7217
01-26 16:19:23.880 30164-6425/cycu.nclab.demo.neuroeeg E/DB_neurosky: saving error on msg.what = 0
01-26 16:19:23.880 30164-30164/cycu.nclab.demo.neuroeeg E/TGDeviceHandler2: In: msg.what = 128, msg.when = 1133169744, msgCount = 7220
01-26 16:19:23.880 30164-6426/cycu.nclab.demo.neuroeeg I/SavingData2: Out: msg.what = 0, msg.when = 0, msgCount = 7218
01-26 16:19:23.880 30164-30164/cycu.nclab.demo.neuroeeg E/TGDeviceHandler2: In: msg.what = 128, msg.when = 1133169745, msgCount = 7221
01-26 16:19:23.880 30164-6426/cycu.nclab.demo.neuroeeg E/DB_neurosky: saving error on msg.what = 0
01-26 16:19:23.880 30164-30164/cycu.nclab.demo.neuroeeg E/TGDeviceHandler2: In: msg.what = 128, msg.when = 1133169745, msgCount = 7222
01-26 16:19:23.880 30164-6428/cycu.nclab.demo.neuroeeg I/SavingData2: Out: msg.what = 0, msg.when = 0, msgCount = 7220
01-26 16:19:23.880 30164-6428/cycu.nclab.demo.neuroeeg E/DB_neurosky: saving error on msg.what = 0
01-26 16:19:23.880 30164-30164/cycu.nclab.demo.neuroeeg E/TGDeviceHandler2: In: msg.what = 128, msg.when = 1133169745, msgCount = 7223
01-26 16:19:23.880 30164-6427/cycu.nclab.demo.neuroeeg I/SavingData2: Out: msg.what = 0, msg.when = 0, msgCount = 7219
01-26 16:19:23.880 30164-6427/cycu.nclab.demo.neuroeeg E/DB_neurosky: saving error on msg.what = 0
01-26 16:19:23.880 30164-6429/cycu.nclab.demo.neuroeeg I/SavingData2: Out: msg.what = 0, msg.when = 0, msgCount = 7221

[補充2]

修改程式碼,在thread中檢查是否有正確的接收到message物件。SavingData.java的程式碼如下

public class SavingData2 implements Runnable {
    private final String TAG = getClass().getSimpleName();
    Message msg;
    Thread myThread;
    private long counter;
    private static long threadCount = 0;

    public long getCounter() { return counter; }
    public static long getThreadCount() { return threadCount; }

    ReentrantLock lock = new ReentrantLock();

    SavingData2(Message msg) {
        this.msg = msg;
        this.counter = threadCount++;
        Log.i(TAG, "Out1: msg.what = " + msg.what + ", msg.when = " + msg.getWhen() + ", msgCount = " + counter++);
        myThread = new Thread(this);
        myThread.start();
    }


    @Override
    public void run() {
        lock.lock();
        Log.i(TAG, "Out: msg.what = " + msg.what + ", msg.when = " + msg.getWhen() + ", msgCount = " + counter++);
        SensingActivity.getDB().insert(msg);
        lock.unlock();
    }
}

我分別在line 16跟25放一個Log來檢查物件,發現在建構子中的物件的確由傳遞進來,然而在run()執行緒中的物件則會變得不確定,如下面的log輸出,因此可能解決這個問題的方法是另外使用一個物件來存放message的內容,不要直接使用message物件。這算是系統的bug還是我的物件導向沒學好XD

01-27 12:37:29.080 18151-18151/cycu.nclab.demo.neuroeeg E/TGDeviceHandler2: In: msg.what = 4, msg.when = 1206254932, msgCount = 0
01-27 12:37:29.080 18151-18151/cycu.nclab.demo.neuroeeg I/SavingData2: Out1: msg.what = 4, msg.when = 1206254932, msgCount = 0
01-27 12:37:29.090 18151-18151/cycu.nclab.demo.neuroeeg E/TGDeviceHandler2: In: msg.what = 4, msg.when = 1206254932, msgCount = 1
01-27 12:37:29.090 18151-18151/cycu.nclab.demo.neuroeeg I/SavingData2: Out1: msg.what = 4, msg.when = 1206254932, msgCount = 1
01-27 12:37:29.100 18151-18151/cycu.nclab.demo.neuroeeg E/TGDeviceHandler2: In: msg.what = 5, msg.when = 1206254932, msgCount = 2
01-27 12:37:29.100 18151-18151/cycu.nclab.demo.neuroeeg I/SavingData2: Out1: msg.what = 5, msg.when = 1206254932, msgCount = 2
01-27 12:37:29.110 18151-18770/cycu.nclab.demo.neuroeeg I/SavingData2: Out: msg.what = 0, msg.when = 0, msgCount = 3
01-27 12:37:29.110 18151-18769/cycu.nclab.demo.neuroeeg I/SavingData2: Out: msg.what = 0, msg.when = 0, msgCount = 2
01-27 12:37:29.110 18151-18770/cycu.nclab.demo.neuroeeg E/DB_neurosky: saving error on msg.what = 0
01-27 12:37:29.110 18151-18769/cycu.nclab.demo.neuroeeg E/DB_neurosky: saving error on msg.what = 0
01-27 12:37:29.120 18151-18768/cycu.nclab.demo.neuroeeg I/SavingData2: Out: msg.what = 0, msg.when = 0, msgCount = 1
01-27 12:37:29.120 18151-18768/cycu.nclab.demo.neuroeeg E/DB_neurosky: saving error on msg.what = 0
01-27 12:37:30.060 18151-18151/cycu.nclab.demo.neuroeeg E/TGDeviceHandler2: In: msg.what = 4, msg.when = 1206255929, msgCount = 3
01-27 12:37:30.060 18151-18151/cycu.nclab.demo.neuroeeg I/SavingData2: Out1: msg.what = 4, msg.when = 1206255929, msgCount = 3
01-27 12:37:30.060 18151-18151/cycu.nclab.demo.neuroeeg E/TGDeviceHandler2: In: msg.what = 4, msg.when = 1206255929, msgCount = 4
01-27 12:37:30.060 18151-18151/cycu.nclab.demo.neuroeeg I/SavingData2: Out1: msg.what = 4, msg.when = 1206255929, msgCount = 4
01-27 12:37:30.060 18151-18151/cycu.nclab.demo.neuroeeg E/TGDeviceHandler2: In: msg.what = 5, msg.when = 1206255929, msgCount = 5
01-27 12:37:30.060 18151-18151/cycu.nclab.demo.neuroeeg I/SavingData2: Out1: msg.what = 5, msg.when = 1206255929, msgCount = 5
01-27 12:37:30.060 18151-18826/cycu.nclab.demo.neuroeeg I/SavingData2: Out: msg.what = 0, msg.when = 0, msgCount = 4
01-27 12:37:30.060 18151-18826/cycu.nclab.demo.neuroeeg E/DB_neurosky: saving error on msg.what = 0
01-27 12:37:30.060 18151-18827/cycu.nclab.demo.neuroeeg I/SavingData2: Out: msg.what = 0, msg.when = 0, msgCount = 5

 

 

發佈留言