_serial = dio_serial($this->_device, $mode, $this->_options); if (!is_resource($this->_serial)) { $error = error_get_last(); if (is_array($error)) { $error = new SerialException($error['message'], 0, $error['type'], $error['file'], $error['line']); throw new SerialException(sprintf('Unable to open the device %s', $this->_device), 0, E_ERROR, null, null, $error); } throw new SerialException(sprintf('Unable to open the device %s', $this->_device)); } return $this; } /** * Binds a named resource, specified by setDevice, to a raw stream. * * @param string $mode * The mode parameter specifies the type of access you require to the stream (as `fopen()`). * * @return SerialDio * @throws SerialException */ public function open_raw (string $mode = 'r+b') : SerialDio { parent::open($mode); error_clear_last(); $this->_serial = dio_raw($this->_device, $mode, $this->_options); if (!is_resource($this->_serial)) { $error = error_get_last(); if (is_array($error)) { $error = new SerialException($error['message'], 0, $error['type'], $error['file'], $error['line']); throw new SerialException(sprintf('Unable to open the device %s', $this->_device), 0, E_ERROR, null, null, $error); } throw new SerialException(sprintf('Unable to open the device %s', $this->_device)); } return $this; } }