protected function waitFrame()
    {
        $frameType = $this->input->readOctet();
        $channel = $this->input->readShort();
        $size = $this->input->readLong();
        $payload = $this->input->read($size);

        $ch = $this->input->readOctet();
        if ($ch != 0xCE) {
            throw new \Exception(
                sprintf(
                    'Framing error, unexpected byte: %x', $ch
                )
            );
        }

        return array($frameType, $channel, $payload);
    }