/// <summary> /// Converts a Cyclic buffer into an int /// </summary> /// <param name="CQ"> The cyclic buffer to be converted into an int </param> /// <param name="offset"> Where to start in the cyclic buffer</param> /// <param name="up">Whether to go up or down the buffer</param> /// <remarks>This does not convert the entire cyclic buffer. Merely the next 4 bytes.</remarks> public static uint ByteToUInt(CyclicQueue CQ, int offset, bool up) { if (up) { uint i = ((uint)CQ[offset + 3] << 24) | ((uint)CQ[offset + 2] << 16) | ((uint)CQ[offset + 1] << 8) | (uint)CQ[offset]; return i; } else { uint i = ((uint)CQ[offset - 3] << 24) | ((uint)CQ[offset - 2] << 16) | ((uint)CQ[offset - 1] << 8) | (uint)CQ[offset]; return i; } }
/// <summary> /// Convert a phrase stored in a cyclic buffer into a string /// </summary> /// <param name="CQ">Cyclic Buffer</param> /// <param name="len">Length of the data in the buffer</param> public static string ByteToString(CyclicQueue CQ, int len) { string str = ""; for (int i = 0; i < len; i++) { str += (char)CQ[i]; } return str; }