private void ProcessChunks(ByteBuffer outBuffer, byte[] data) { int offs = 0; while (offs < data.Length) { Debug.Assert(JHI.StrEq(data, offs + 0x00, JHIMccBuf.MAGIC_CODE)); int chunkSize = JHI.SwapBytes(BitConverter.ToInt16(data, offs + 0x04)); offs += 0x06; outBuffer.Write(data, offs, chunkSize); offs += chunkSize; // Align to 0x20. offs = (offs + 0x1F) & ~0x1F; } }
public byte[] ReadData() { SyncPointsFromHIO2(); if (this.pointW == this.pointR) { // Empty, nothing to read. return(null); } int size = this.pointW - this.pointR; if (size < 0) { size += this.bufDataSize; } byte[] data = new byte[size]; int data_offs = 0x00; // Check for wraparound -- where the new WP is less than our RP. // In this case, we need to split the read into two. if (this.pointW < this.pointR) { // First, read from pointW until end of buffer. int size1 = this.bufDataSize - this.pointR; hio2.ReadBytes(ref data, data_offs, this.baseOffset + DATA_OFFSET + this.pointR, size1); data_offs += size1; size -= size1; // Reset pointR back to the start to prepare for the next read. this.pointR = 0; } hio2.ReadBytes(ref data, data_offs, this.baseOffset + DATA_OFFSET + this.pointR, size); Debug.Assert(JHI.StrEq(data, 0, MAGIC_CODE)); // Update our read point to match. this.pointR = this.pointW; SyncReadPointToHIO2(); return(data); }
public bool IsReady() { return(JHI.StrEq(hio2.ReadBytes(MAGIC_OFFSET, 4), 0, MAGIC_CODE)); }
public bool HasDisconnectCode() { return(JHI.StrEq(ReadBytes(0x04, 0x04), 0x00, DISCONNECT_CODE)); }
public bool IsConnected() { return(JHI.StrEq(ReadBytes(0x00, 0x04), 0x00, JHIMccBuf.MAGIC_CODE)); }