public void SetByteString(int index, string byteString) { if (byteString == null) { throw new ArgumentNullException(nameof(byteString)); } if (byteString.Length == 1) { byteString = "0" + byteString; } else if (byteString.Length != 2) { throw new IndexOutOfRangeException("Byte" + index.ToString() + " must have a length of 2"); } if (index > 7) { throw new IndexOutOfRangeException("Max index for a SetByteString operation is 7"); } int pos = 22 + index; ReplaceRawBytes(CanUtilities.StringToByteArray(byteString), pos, 1); }
private static bool CheckIfTritiumDatagram(byte[] data) { string dataString = CanUtilities.ByteArrayToText(data); // Some tritium Can Bridges uses Tritiub rather that Tritium // The latest release seems to just use Tri return(dataString.Contains("Tri")); }
public void SetUint8(int index, uint newUInt) { if (index > 7) { throw new IndexOutOfRangeException("Max index for a setUInt8 operation is 7"); } int pos = 22 + index; RawBytes[pos] = CanUtilities.UInt8ToByte(newUInt); }
public uint GetUint8(int index) { if (index > 7) { throw new IndexOutOfRangeException("Max index for a setUInt8 operation is 7"); } int pos = 22 + index; return(CanUtilities.ByteToUInt8(RawBytes.Skip(pos).Take(1).ToArray())); }
public string GetByteString(int index) { if (index > 7) { throw new IndexOutOfRangeException("Max index for a GetByteString operation is 7"); } int pos = 22 + index; return(CanUtilities.ByteArrayToString(RawBytes.Skip(pos).Take(1).ToArray())); }