public void GotCANFrame(CANFrame frame)
        {
            int found = -1;

            for (int x = 0; x < foundID.Count; x++)
            {
                if (foundID[x].ID == frame.ID)
                {
                    found = x;
                    break;
                }
            }

            if (found == -1)
            {
                UniqueFrameData tempData = new UniqueFrameData();
                tempData.ID = frame.ID;
                tempData.referenceBitfield = bytesToUInt64(frame.data);
                tempData.staticBits        = 0xFFFFFFFFFFFFFFFF; //that'd be 64 binary 1's
                foundID.Add(tempData);
            }

            UInt64 newdata  = bytesToUInt64(frame.data);
            UInt64 bitDiffs = newdata ^ foundID[found].referenceBitfield;

            //The above XOR will cause bitDiffs to have a 1 anywhere the bits were different.
            //This would be wherever a change occurred in bits from the reference.
            //This needs to be inverted so that a 1 appears wherever the bits were the same.
            bitDiffs = ~bitDiffs;
            //Now that we've got a variable with a 1 in the bit positions that did not change
            //we can AND it with the staticBits member for the frame ID. This will cause there to be a 1
            //in this field only where 1 is currently there and in the bitDiffs variable. The
            //end result is that staticBits will only have a 1 where the bits have NEVER changed
            //in any frame we've seen. These are candidates for trying to find a switched value.
            UInt64 staticTemp = foundID[found].staticBits & bitDiffs;

            if (initialBaseline)
            {
                //Since this is the initial baseline we store the new static bits
                foundID[found].staticBits = staticTemp;
            }
            else
            {
                //initial baseline is already complete so compare the result to what is stored. See if there is a change
                if (foundID[found].staticBits != staticTemp)
                {
                }
            }
            //enqueue frame
            frameCache.Add(frame);
        }
Example #2
0
        public void GotCANFrame(CANFrame frame)
        {
            int found = -1;
            for (int x = 0; x < foundID.Count; x++)
            {
                if (foundID[x].ID == frame.ID)
                {
                    found = x;
                    break;
                }
            }

            if (found == -1)
            {
                UniqueFrameData tempData = new UniqueFrameData();
                tempData.ID = frame.ID;
                tempData.referenceBitfield = bytesToUInt64(frame.data);
                tempData.staticBits = 0xFFFFFFFFFFFFFFFF; //that'd be 64 binary 1's
                foundID.Add(tempData);   
            }

            UInt64 newdata = bytesToUInt64(frame.data);
            UInt64 bitDiffs = newdata ^ foundID[found].referenceBitfield;
            //The above XOR will cause bitDiffs to have a 1 anywhere the bits were different.
            //This would be wherever a change occurred in bits from the reference.
            //This needs to be inverted so that a 1 appears wherever the bits were the same.
            bitDiffs = ~bitDiffs;
            //Now that we've got a variable with a 1 in the bit positions that did not change
            //we can AND it with the staticBits member for the frame ID. This will cause there to be a 1
            //in this field only where 1 is currently there and in the bitDiffs variable. The
            //end result is that staticBits will only have a 1 where the bits have NEVER changed
            //in any frame we've seen. These are candidates for trying to find a switched value.
            UInt64 staticTemp = foundID[found].staticBits & bitDiffs;

            if (initialBaseline)
            {
                //Since this is the initial baseline we store the new static bits
                foundID[found].staticBits = staticTemp;
            }
            else
            {
                //initial baseline is already complete so compare the result to what is stored. See if there is a change
                if (foundID[found].staticBits != staticTemp)
                {

                }
            }
            //enqueue frame
            frameCache.Add(frame);
        }