/** * {@inheritdoc} */ public function read(StreamInterface $stream, DataSet $result) { $data = $stream->read(2); if (strlen($data) < 2) { $data = str_pad($data, 2, "", STR_PAD_LEFT); } $unpacked = unpack('S', $data); $this->validate($unpacked[1]); $result->setValue($this->getName(), $unpacked[1]); }
/** * {@inheritdoc} */ public function read(StreamInterface $stream, DataSet $result) { $vec = array(); for ($i = 0; $i < 3; $i++) { $data = $stream->read(4); if (strlen($data) < 2) { $data = str_pad($data, 2, "", STR_PAD_LEFT); } $unpacked = unpack('f', $data); $this->validate($unpacked[1]); $vec[$i] = $unpacked[1]; } $result->setValue($this->name, $vec); }
/** * {@inheritdoc} */ public function read(StreamInterface $stream, DataSet $result) { $result->push($this->name); // Read the bytes into memory $byte = $stream->readByte(); $bitPosition = 0; // Get the structure $structure = $this->structure->get(); foreach ($structure as $bitFieldName => $bitFieldSize) { $value = ord($byte) >> $bitPosition & bindec(str_repeat('1', $bitFieldSize)); $result->setValue($bitFieldName, $value); $bitPosition += $bitFieldSize; } $result->pop(); }