public UInt64 ExtractBits(CanSignalType signal) { if (signal.Encoding == SignalEncoding.Motorola) { throw new Exception("Motorola byte order not supported"); } var bits = ExtractBits(signal.StartBit, signal.BitMask); if (signal.Type == SignalType.Signed) { bits = TwosComplementCompensation(bits, signal.Length); } return(bits); }
public ulong ExtractBits(CanSignalType signal) { if (signal.Encoding == SignalEncoding.Motorola) { throw new Exception("Motorola byte order not supported"); } // TODO: Check if the bitmask has been calculated // Isolate relevant bits using precalculated bitmask UInt64 bits = Data; bits &= signal.BitMask; // Shift back to original state according to specification bits >>= signal.StartBit; return(bits); }
public void InsertBits(CanSignalType signal, UInt64 bits) { InsertBits(signal.StartBit, signal.BitMask, bits); }