android处理程序传输中的数据丢失

时间:2014-10-03 20:52:41

标签: android android-fragments bluetooth data-transfer data-synchronization

我有一个与蓝牙目标设备通信的系统,该设备在Android系统上的动作上发送命令字符串,并在时钟序列上接收来自目标的数据。传出数据没有明显的问题,但我在蓝牙服务例程和呈现给UI的片段之间间歇性地丢失数据。

Android应用程序内的通信路径是:

  • 根据示例的蓝牙服务例程。输入数据流的第一个字节用于指示包含的信息类型:该字节被剥离,其余部分重新组装成固定长度的字节数组dataBuffer []。然后使用mHandler.obtainMessage()将此数组返回到主机活动。

代码的相关部分是:

/*
* This thread runs during a connection with a remote device.
* It handles all incoming and outgoing transmissions.
*/
private class ConnectedThread extends Thread 
{
   private static final byte enq = 5;
   private final BluetoothSocket mmSocket;
   private final InputStream mmInStream;
   private final OutputStream mmOutStream;

   public ConnectedThread(BluetoothSocket socket, String socketType) 
   {
       if (D) Log.d(TAG, "498 - create ConnectedThread: " + socketType);
       mmSocket = socket;
       InputStream tmpIn = null;
       OutputStream tmpOut = null;
     // Get the BluetoothSocket input and output streams
       try 
       {
           tmpIn = socket.getInputStream();
           tmpOut = socket.getOutputStream();
       } 
       catch (IOException e) 
       {
           Log.e(TAG, "510 - temp sockets not created", e);
       }
       mmInStream = tmpIn;
       mmOutStream = tmpOut;
   }

   public void run() 
   {
       if (D) Log.i(TAG, "518 - Begin mConnectedThread");
       int bytes;
       int dataCount = 0;
     // Keep listening to the InputStream while connected
       while (true) 
       {
           try 
           {
             // Read from the InputStream
               byte[] inBuffer = new byte[128];
               int bufferPtr = 0;
               bytes = mmInStream.read(inBuffer);
               if (D) Log.e(TAG, "530 - InStream length = : " + bytes + " bytes: ");
               for (int i=0; i<bytes; i++)
               {
                   if (D) Log.e(TAG, "533 - inBuffer[" + i + "] - " + Integer.toHexString(inBuffer[i] & 0xFF) + " - " + (char)inBuffer[i] );
               }

               while(bufferPtr<bytes)
               {
//                 if (D) Log.e(TAG, " 538 - dataIn = " + dataIn + "  : ctlIn = " + ctlIn);
                   if (!dataIn && !ctlIn )
                   {
                       if (inBuffer[bufferPtr] == enq)              // Is it a new data message?
                       {
                           if (D) Log.e(TAG, "543 - New data stream in" );
                           dataIn = true;
                           Arrays.fill(dataBuffer,(byte)0);
                           bufferPtr++;
                           dataCount = 0;
                       }
                       else                         // Must be a new control command
                       {
                           // It's a control message
                       }
                   }
                   if (dataIn && (bufferPtr<bytes))
                   {
                       if (dataCount<dataItems)
                       {
                           dataBuffer[dataCount] = inBuffer[bufferPtr];
                           dataCount++;
                           bufferPtr++;
                           if(D) Log.e(TAG, "565 - dataBuffer[" + (dataCount-1) +"] - " + Integer.toHexString(dataBuffer[dataCount-1] & 0xFF));
                       }
                       else
                       {
                           dataIn = false;
                           for (int i=0; i<dataBuffer.length; i++)
                           {
                               if (D) Log.e(TAG, "573 - DataInArray[" + i + "] = " + Integer.toHexString(dataBuffer[i] & 0xFF));
                           }
                           mHandler.obtainMessage(BaseActivity.DATA_MESSAGE_IN, dataBuffer.length, -1, dataBuffer).sendToTarget();
                           if (D) Log.e(TAG, "576 - " + dataItems + " bytes received. Data stream sent to host ##" );
                       }
                   }
                   if (ctlIn)
                   {
                       // It'a control message                         
                   }
               }
               // Send the obtained bytes to the UI Activity
           } 
           catch (IOException e) 
           {
               Log.e(TAG, "604 - disconnected", e);
               connectionLost();
               // Start the service over to restart listening mode
               BtService.this.start();
               break;
           }
       }
   }
  • 传入的数据流被传递回基本活动,在那里它用于构建字节数组dataIn [] - 然后将该数组直接传递给Fragment进行显示。 (我希望最终能够将传入的数据重定向到不同的片段。)

基本活动中的处理程序代码为:

@Override
public void handleMessage(Message msg) 
{
    if(D) Log.e(TAG, "427 - << Handler message received: >> " + msg.what);
    switch (msg.what) 
    {
        case MESSAGE_STATE_CHANGE:
                // Deal with state change
                break;

            case MESSAGE_OUT:
                // Deal with outgoing message
                break;

            case CONTROL_MESSAGE_IN:
                // Deal with incoming control message
                break;

            case DATA_MESSAGE_IN:
                dataIn = (byte[]) msg.obj;
                int dataMsgLength = msg.arg1;
                if (D) Log.e(TAG, "490 - Received data stream: length = " + msg.arg1 + " bytes:");
                for (int i=0; i<dataMsgLength; i++)
                {
                    if (D) Log.e(TAG, "494 - DataIn[" + i + "] - " + Integer.toHexString(dataIn[i] & 0xFF));
                }
                Hmi2Fragment.updateDisplay(dataIn);
                break;

            case MESSAGE_DEVICE_NAME:
                // save the connected device's name
                break;

            case MESSAGE_TOAST:
                // Deal with Toast
                break;

            case FILE_SELECTED:
                // Deal with file
                break;
        }
    }
};
  • 然后将接收到的数据数组传递给Fragment Hmi2,在那里显示它。这个代码是: //主机活动调用的方法,用于更新显示的数据。 public static void updateDisplay(byte [] inDataBytes) {     for(int i = 0; i

            if ((k & 2) != 0) bst[1].setImageLevel(1);
            else bst[1].setImageLevel(0);
            bst[1].invalidate();
        }
        else
        {
            for (int j=0; j<8; j++)
            {
                int indNo = mapIn[i-1][j];
                if ((indNo == 0) || (indNo >0))
                {
                    if ((k & (1 << j)) != 0) ind[indNo].setImageLevel(1);
                    else  ind[indNo].setImageLevel(0);
                    ind[indNo].invalidate();
                }
            }
        }
    }
    

问题在于,当我运行应用程序并使用Logcat跟踪通过管道的数据流时,数组并没有像我期望的那样相互跟踪。

良好转移的一个例子是:

10-04 09:09:14.643  E/C&C Bluetooth(4304)   530 - InStream length = 1 bytes
10-04 09:09:14.643  E/C&C Bluetooth(4304)   533 - inBuffer[0] - 5 -  
10-04 09:09:14.643  E/C&C Bluetooth(4304)   573 - DataInArray[0] = 1
10-04 09:09:14.643  E/C&C Bluetooth(4304)   573 - DataInArray[1] = 95
10-04 09:09:14.643  E/C&C Bluetooth(4304)   573 - DataInArray[2] = 0
10-04 09:09:14.643  E/C&C Bluetooth(4304)   573 - DataInArray[3] = 18
10-04 09:09:14.653  E/C&C Bluetooth(4304)   573 - DataInArray[4] = 2
10-04 09:09:14.653  E/C&C Bluetooth(4304)   573 - DataInArray[5] = e4
10-04 09:09:14.653  E/C&C Bluetooth(4304)   573 - DataInArray[6] = 2
10-04 09:09:14.653  E/C&C Bluetooth(4304)   573 - DataInArray[7] = 0
10-04 09:09:14.663  E/C&C Bluetooth(4304)   573 - DataInArray[8] = 0
10-04 09:09:14.663  E/C&C Bluetooth(4304)   573 - DataInArray[9] = 0
10-04 09:09:14.663  E/C&C Bluetooth(4304)   573 - DataInArray[10] = 0
10-04 09:09:14.663  E/C&C Bluetooth(4304)   576 - 11 bytes received. Data stream sent to host ##
10-04 09:09:14.663  E/C&C Bluetooth(4304)   543 - New data stream in
10-04 09:09:14.663  E/C&C Bluetooth(4304)   530 - InStream length = 11 bytes
10-04 09:09:14.663  E/C&C Bluetooth(4304)   533 - inBuffer[0] - 1 -  
10-04 09:09:14.673  E/C&C Bluetooth(4304)   533 - inBuffer[1] - 95 - ユ
10-04 09:09:14.673  E/C&C Bluetooth(4304)   533 - inBuffer[2] - 0 - ��
10-04 09:09:14.673  E/C&C Bluetooth(4304)   533 - inBuffer[3] - 3a - :
10-04 09:09:14.673  E/C&C Bluetooth(4304)   533 - inBuffer[4] - 2 -  
10-04 09:09:14.673  E/C&C Bluetooth(4304)   533 - inBuffer[5] - e3 -  ̄
10-04 09:09:14.673  E/C&C Bluetooth(4304)   533 - inBuffer[6] - 2 -  
10-04 09:09:14.673  E/C&C Bluetooth(4304)   533 - inBuffer[7] - 0 - ��
10-04 09:09:14.673  E/C&C Bluetooth(4304)   533 - inBuffer[8] - 0 - ��
10-04 09:09:14.673  E/C&C Bluetooth(4304)   533 - inBuffer[9] - 0 - ��
10-04 09:09:14.673  E/C&C Bluetooth(4304)   533 - inBuffer[10] - 0 - ��
10-04 09:09:14.673  E/C&C Bluetooth(4304)   565 - dataBuffer[0] - 1
10-04 09:09:14.673  E/C&C Bluetooth(4304)   565 - dataBuffer[1] - 95
10-04 09:09:14.673  E/C&C Bluetooth(4304)   565 - dataBuffer[2] - 0
10-04 09:09:14.673  E/C&C Bluetooth(4304)   565 - dataBuffer[3] - 3a
10-04 09:09:14.673  E/C&C Bluetooth(4304)   565 - dataBuffer[4] - 2
10-04 09:09:14.683  E/C&C Bluetooth(4304)   565 - dataBuffer[5] - e3
10-04 09:09:14.683  E/C&C Bluetooth(4304)   565 - dataBuffer[6] - 2
10-04 09:09:14.683  E/C&C Bluetooth(4304)   565 - dataBuffer[7] - 0
10-04 09:09:14.683  E/C&C Bluetooth(4304)   565 - dataBuffer[8] - 0
10-04 09:09:14.683  E/C&C Bluetooth(4304)   565 - dataBuffer[9] - 0
10-04 09:09:14.683  E/C&C Bluetooth(4304)   565 - dataBuffer[10] - 0

10-04 09:09:14.663  E/C&C Base(4304)    427 - << Handler message received >> 4
10-04 09:09:14.663  E/C&C Base(4304)    490 - Received data stream  length = 11 bytes:
10-04 09:09:14.663  E/C&C Base(4304)    494 - DataIn[0] - 1
10-04 09:09:14.663  E/C&C Base(4304)    494 - DataIn[1] - 95
10-04 09:09:14.663  E/C&C Base(4304)    494 - DataIn[2] - 0
10-04 09:09:14.663  E/C&C Base(4304)    494 - DataIn[3] - 18
10-04 09:09:14.663  E/C&C Base(4304)    494 - DataIn[4] - 2
10-04 09:09:14.663  E/C&C Base(4304)    494 - DataIn[5] - e4
10-04 09:09:14.663  E/C&C Base(4304)    494 - DataIn[6] - 2
10-04 09:09:14.663  E/C&C Base(4304)    494 - DataIn[7] - 0
10-04 09:09:14.663  E/C&C Base(4304)    494 - DataIn[8] - 0
10-04 09:09:14.663  E/C&C Base(4304)    494 - DataIn[9] - 0
10-04 09:09:14.663  E/C&C Base(4304)    494 - DataIn[10] - 0

10-04 09:09:14.663  E/C&C HMI2(4304)    260 - inDataBytes[0] - 1
10-04 09:09:14.663  E/C&C HMI2(4304)    260 - inDataBytes[1] - 95
10-04 09:09:14.663  E/C&C HMI2(4304)    260 - inDataBytes[2] - 0
10-04 09:09:14.663  E/C&C HMI2(4304)    260 - inDataBytes[3] - 18
10-04 09:09:14.663  E/C&C HMI2(4304)    260 - inDataBytes[4] - 2
10-04 09:09:14.663  E/C&C HMI2(4304)    260 - inDataBytes[5] - e4
10-04 09:09:14.663  E/C&C HMI2(4304)    260 - inDataBytes[6] - 2
10-04 09:09:14.663  E/C&C HMI2(4304)    260 - inDataBytes[7] - 0
10-04 09:09:14.663  E/C&C HMI2(4304)    260 - inDataBytes[8] - 0
10-04 09:09:14.663  E/C&C HMI2(4304)    260 - inDataBytes[9] - 0
10-04 09:09:14.663  E/C&C HMI2(4304)    260 - inDataBytes[10] - 0
10-04 09:09:14.683  E/C&C HMI2(4304)    295 - i = 0  lsb = 58 msb = 2
10-04 09:09:14.683  E/C&C HMI2(4304)    297 - val[0] = 55.0
10-04 09:09:14.683  E/C&C HMI2(4304)    295 - i = 1  lsb = 227 msb = 2
10-04 09:09:14.683  E/C&C HMI2(4304)    297 - val[1] = 72.0
10-04 09:09:14.683  E/C&C HMI2(4304)    295 - i = 2  lsb = 0 msb = 0
10-04 09:09:14.683  E/C&C HMI2(4304)    297 - val[2] = -1.0
10-04 09:09:14.693  E/C&C HMI2(4304)    295 - i = 3  lsb = 0 msb = 0
10-04 09:09:14.693  E/C&C HMI2(4304)    297 - val[3] = -1.0

基本活动与片段之间失败的一个例子是:

10-04 09:09:14.883  E/C&C Bluetooth(4304)   530 - InStream length = 1 bytes
10-04 09:09:14.883  E/C&C Bluetooth(4304)   533 - inBuffer[0] - 5 -  
10-04 09:09:14.893  E/C&C Bluetooth(4304)   573 - DataInArray[0] = 1
10-04 09:09:14.893  E/C&C Bluetooth(4304)   573 - DataInArray[1] = 95
10-04 09:09:14.893  E/C&C Bluetooth(4304)   573 - DataInArray[2] = 0
10-04 09:09:14.893  E/C&C Bluetooth(4304)   573 - DataInArray[3] = 3a
10-04 09:09:14.893  E/C&C Bluetooth(4304)   573 - DataInArray[4] = 2
10-04 09:09:14.893  E/C&C Bluetooth(4304)   573 - DataInArray[5] = e3
10-04 09:09:14.893  E/C&C Bluetooth(4304)   573 - DataInArray[6] = 2
10-04 09:09:14.893  E/C&C Bluetooth(4304)   573 - DataInArray[7] = 0
10-04 09:09:14.903  E/C&C Bluetooth(4304)   573 - DataInArray[8] = 0
10-04 09:09:14.903  E/C&C Bluetooth(4304)   573 - DataInArray[9] = 0
10-04 09:09:14.903  E/C&C Bluetooth(4304)   573 - DataInArray[10] = 0
10-04 09:09:14.913  E/C&C Bluetooth(4304)   576 - 11 bytes received. Data stream sent to host ##
10-04 09:09:14.913  E/C&C Bluetooth(4304)   543 - New data stream in
10-04 09:09:14.923  E/C&C Bluetooth(4304)   530 - InStream length = 11 bytes
10-04 09:09:14.923  E/C&C Bluetooth(4304)   533 - inBuffer[0] - 1 -  
10-04 09:09:14.923  E/C&C Bluetooth(4304)   533 - inBuffer[1] - 95 - ユ
10-04 09:09:14.923  E/C&C Bluetooth(4304)   533 - inBuffer[2] - 0 - ��
10-04 09:09:14.923  E/C&C Bluetooth(4304)   533 - inBuffer[3] - 59 - Y
10-04 09:09:14.923  E/C&C Bluetooth(4304)   533 - inBuffer[4] - 2 -  
10-04 09:09:14.923  E/C&C Bluetooth(4304)   533 - inBuffer[5] - e4 - ¦
10-04 09:09:14.923  E/C&C Bluetooth(4304)   533 - inBuffer[6] - 2 -  
10-04 09:09:14.933  E/C&C Bluetooth(4304)   533 - inBuffer[7] - 0 - ��
10-04 09:09:14.933  E/C&C Bluetooth(4304)   533 - inBuffer[8] - 0 - ��
10-04 09:09:14.933  E/C&C Bluetooth(4304)   533 - inBuffer[9] - 0 - ��
10-04 09:09:14.933  E/C&C Bluetooth(4304)   533 - inBuffer[10] - 0 - ��
10-04 09:09:14.933  E/C&C Bluetooth(4304)   565 - dataBuffer[0] - 1
10-04 09:09:14.943  E/C&C Bluetooth(4304)   565 - dataBuffer[1] - 95
10-04 09:09:14.943  E/C&C Bluetooth(4304)   565 - dataBuffer[2] - 0
10-04 09:09:14.943  E/C&C Bluetooth(4304)   565 - dataBuffer[3] - 59
10-04 09:09:14.943  E/C&C Bluetooth(4304)   565 - dataBuffer[4] - 2
10-04 09:09:14.943  E/C&C Bluetooth(4304)   565 - dataBuffer[5] - e4
10-04 09:09:14.943  E/C&C Bluetooth(4304)   565 - dataBuffer[6] - 2
10-04 09:09:14.943  E/C&C Bluetooth(4304)   565 - dataBuffer[7] - 0
10-04 09:09:14.953  E/C&C Bluetooth(4304)   565 - dataBuffer[8] - 0
10-04 09:09:14.953  E/C&C Bluetooth(4304)   565 - dataBuffer[9] - 0
10-04 09:09:14.953  E/C&C Bluetooth(4304)   565 - dataBuffer[10] - 0

10-04 09:09:14.903  E/C&C Base(4304)    427 - << Handler message received >> 4
10-04 09:09:14.903  E/C&C Base(4304)    490 - Received data stream length = 11 bytes:
10-04 09:09:14.903  E/C&C Base(4304)    494 - DataIn[0] - 1
10-04 09:09:14.903  E/C&C Base(4304)    494 - DataIn[1] - 95
10-04 09:09:14.903  E/C&C Base(4304)    494 - DataIn[2] - 0
10-04 09:09:14.903  E/C&C Base(4304)    494 - DataIn[3] - 3a
10-04 09:09:14.903  E/C&C Base(4304)    494 - DataIn[4] - 2
10-04 09:09:14.913  E/C&C Base(4304)    494 - DataIn[5] - e3
10-04 09:09:14.913  E/C&C Base(4304)    494 - DataIn[6] - 2
10-04 09:09:14.913  E/C&C Base(4304)    494 - DataIn[7] - 0
10-04 09:09:14.913  E/C&C Base(4304)    494 - DataIn[8] - 0
10-04 09:09:14.913  E/C&C Base(4304)    494 - DataIn[9] - 0
10-04 09:09:14.913  E/C&C Base(4304)    494 - DataIn[10] - 0

10-04 09:09:14.913  E/C&C HMI2(4304)    260 - inDataBytes[0] - 0
10-04 09:09:14.913  E/C&C HMI2(4304)    260 - inDataBytes[1] - 0
10-04 09:09:14.913  E/C&C HMI2(4304)    260 - inDataBytes[2] - 0
10-04 09:09:14.913  E/C&C HMI2(4304)    260 - inDataBytes[3] - 0
10-04 09:09:14.923  E/C&C HMI2(4304)    260 - inDataBytes[4] - 0
10-04 09:09:14.923  E/C&C HMI2(4304)    260 - inDataBytes[5] - 0
10-04 09:09:14.923  E/C&C HMI2(4304)    260 - inDataBytes[6] - 0
10-04 09:09:14.933  E/C&C HMI2(4304)    260 - inDataBytes[7] - 0
10-04 09:09:14.933  E/C&C HMI2(4304)    260 - inDataBytes[8] - 0
10-04 09:09:14.933  E/C&C HMI2(4304)    260 - inDataBytes[9] - 0
10-04 09:09:14.933  E/C&C HMI2(4304)    260 - inDataBytes[10] - 0
10-04 09:09:14.973  E/C&C HMI2(4304)    295 - i = 0  lsb = 89 msb = 2
10-04 09:09:14.973  E/C&C HMI2(4304)    297 - val[0] = 58.0
10-04 09:09:14.973  E/C&C HMI2(4304)    295 - i = 1  lsb = 228 msb = 2
10-04 09:09:14.973  E/C&C HMI2(4304)    297 - val[1] = 72.0
10-04 09:09:14.983  E/C&C HMI2(4304)    295 - i = 2  lsb = 0 msb = 0
10-04 09:09:14.983  E/C&C HMI2(4304)    297 - val[2] = -1.0
10-04 09:09:14.983  E/C&C HMI2(4304)    295 - i = 3  lsb = 0 msb = 0
10-04 09:09:14.983  E/C&C HMI2(4304)    297 - val[3] = -1.0

以及服务与活动之间的数据丢失:

10-04 09:09:16.453  E/C&C Bluetooth(4304)   530 - InStream length = 2 bytes
10-04 09:09:16.453  E/C&C Bluetooth(4304)   533 - inBuffer[0] - 5 -  
10-04 09:09:16.453  E/C&C Bluetooth(4304)   533 - inBuffer[1] - 1 -  
10-04 09:09:16.453  E/C&C Bluetooth(4304)   573 - DataInArray[0] = 1
10-04 09:09:16.453  E/C&C Bluetooth(4304)   573 - DataInArray[1] = 95
10-04 09:09:16.453  E/C&C Bluetooth(4304)   573 - DataInArray[2] = 0
10-04 09:09:16.463  E/C&C Bluetooth(4304)   573 - DataInArray[3] = ed
10-04 09:09:16.463  E/C&C Bluetooth(4304)   573 - DataInArray[4] = 2
10-04 09:09:16.463  E/C&C Bluetooth(4304)   573 - DataInArray[5] = e4
10-04 09:09:16.463  E/C&C Bluetooth(4304)   573 - DataInArray[6] = 2
10-04 09:09:16.463  E/C&C Bluetooth(4304)   573 - DataInArray[7] = 0
10-04 09:09:16.463  E/C&C Bluetooth(4304)   573 - DataInArray[8] = 0
10-04 09:09:16.463  E/C&C Bluetooth(4304)   573 - DataInArray[9] = 0
10-04 09:09:16.463  E/C&C Bluetooth(4304)   573 - DataInArray[10] = 0
10-04 09:09:16.463  E/C&C Bluetooth(4304)   576 - 11 bytes received. Data stream sent to host ##
10-04 09:09:16.463  E/C&C Bluetooth(4304)   543 - New data stream in
10-04 09:09:16.463  E/C&C Bluetooth(4304)   565 - dataBuffer[0] - 1
10-04 09:09:16.473  E/C&C Bluetooth(4304)   530 - InStream length = 10 bytes
10-04 09:09:16.473  E/C&C Bluetooth(4304)   533 - inBuffer[0] - 95 - ユ
10-04 09:09:16.473  E/C&C Bluetooth(4304)   533 - inBuffer[1] - 0 - ��
10-04 09:09:16.473  E/C&C Bluetooth(4304)   533 - inBuffer[2] - d - 
10-04 09:09:16.473  E/C&C Bluetooth(4304)   533 - inBuffer[3] - 3 -  
10-04 09:09:16.473  E/C&C Bluetooth(4304)   533 - inBuffer[4] - e4 - ¦
10-04 09:09:16.473  E/C&C Bluetooth(4304)   533 - inBuffer[5] - 2 -  
10-04 09:09:16.473  E/C&C Bluetooth(4304)   533 - inBuffer[6] - 0 - ��
10-04 09:09:16.473  E/C&C Bluetooth(4304)   533 - inBuffer[7] - 0 - ��
10-04 09:09:16.473  E/C&C Bluetooth(4304)   533 - inBuffer[8] - 0 - ��
10-04 09:09:16.473  E/C&C Bluetooth(4304)   533 - inBuffer[9] - 0 - ��
10-04 09:09:16.483  E/C&C Bluetooth(4304)   565 - dataBuffer[1] - 95
10-04 09:09:16.483  E/C&C Bluetooth(4304)   565 - dataBuffer[2] - 0
10-04 09:09:16.483  E/C&C Bluetooth(4304)   565 - dataBuffer[3] - d
10-04 09:09:16.483  E/C&C Bluetooth(4304)   565 - dataBuffer[4] - 3
10-04 09:09:16.483  E/C&C Bluetooth(4304)   565 - dataBuffer[5] - e4
10-04 09:09:16.483  E/C&C Bluetooth(4304)   565 - dataBuffer[6] - 2
10-04 09:09:16.483  E/C&C Bluetooth(4304)   565 - dataBuffer[7] - 0
10-04 09:09:16.483  E/C&C Bluetooth(4304)   565 - dataBuffer[8] - 0
10-04 09:09:16.483  E/C&C Bluetooth(4304)   565 - dataBuffer[9] - 0
10-04 09:09:16.483  E/C&C Bluetooth(4304)   565 - dataBuffer[10] - 0

10-04 09:09:16.463  E/C&C Base(4304)    427 - << Handler message received >> 4
10-04 09:09:16.473  E/C&C Base(4304)    490 - Received data stream length = 11 bytes:
10-04 09:09:16.473  E/C&C Base(4304)    494 - DataIn[0] - 1
10-04 09:09:16.473  E/C&C Base(4304)    494 - DataIn[1] - 0
10-04 09:09:16.473  E/C&C Base(4304)    494 - DataIn[2] - 0
10-04 09:09:16.473  E/C&C Base(4304)    494 - DataIn[3] - 0
10-04 09:09:16.473  E/C&C Base(4304)    494 - DataIn[4] - 0
10-04 09:09:16.473  E/C&C Base(4304)    494 - DataIn[5] - 0
10-04 09:09:16.473  E/C&C Base(4304)    494 - DataIn[6] - 0
10-04 09:09:16.473  E/C&C Base(4304)    494 - DataIn[7] - 0
10-04 09:09:16.473  E/C&C Base(4304)    494 - DataIn[8] - 0
10-04 09:09:16.473  E/C&C Base(4304)    494 - DataIn[9] - 0
10-04 09:09:16.473  E/C&C Base(4304)    494 - DataIn[10] - 0

10-04 09:09:16.473  E/C&C HMI2(4304)    260 - inDataBytes[0] - 1
10-04 09:09:16.473  E/C&C HMI2(4304)    260 - inDataBytes[1] - 0
10-04 09:09:16.473  E/C&C HMI2(4304)    260 - inDataBytes[2] - 0
10-04 09:09:16.483  E/C&C HMI2(4304)    260 - inDataBytes[3] - 0
10-04 09:09:16.483  E/C&C HMI2(4304)    260 - inDataBytes[4] - 3
10-04 09:09:16.483  E/C&C HMI2(4304)    260 - inDataBytes[5] - e4
10-04 09:09:16.483  E/C&C HMI2(4304)    260 - inDataBytes[6] - 2
10-04 09:09:16.483  E/C&C HMI2(4304)    260 - inDataBytes[7] - 0
10-04 09:09:16.483  E/C&C HMI2(4304)    260 - inDataBytes[8] - 0
10-04 09:09:16.483  E/C&C HMI2(4304)    260 - inDataBytes[9] - 0
10-04 09:09:16.483  E/C&C HMI2(4304)    260 - inDataBytes[10] - 0
10-04 09:09:16.493  E/C&C HMI2(4304)    295 - i = 0  lsb = 13 msb = 3
10-04 09:09:16.493  E/C&C HMI2(4304)    297 - val[0] = 76.0
10-04 09:09:16.493  E/C&C HMI2(4304)    295 - i = 1  lsb = 228 msb = 2
10-04 09:09:16.493  E/C&C HMI2(4304)    297 - val[1] = 72.0
10-04 09:09:16.493  E/C&C HMI2(4304)    295 - i = 2  lsb = 0 msb = 0
10-04 09:09:16.493  E/C&C HMI2(4304)    297 - val[2] = -1.0
10-04 09:09:16.493  E/C&C HMI2(4304)    295 - i = 3  lsb = 0 msb = 0
10-04 09:09:16.493  E/C&C HMI2(4304)    297 - val[3] = -1.0

在我看来,似乎某个地方存在同步问题,但我看不出任何明显的数据消失方式。

编辑:它确实是一个同步问题 - 删除arrays.fill命令可以在更新字节数组时停止问题,而不是清除和重新加载。 欢迎任何建议!

0 个答案:

没有答案