src/PhpSerial.php
public function deviceOpen($mode = "r+b")
    {
        if ($this->_dState === SERIAL_DEVICE_OPENED) {
            trigger_error("The device is already opened", E_USER_NOTICE);

            return true;
        }

        if ($this->_dState === SERIAL_DEVICE_NOTSET) {
            trigger_error(
                "The device must be set before to be open",
                E_USER_WARNING
            );

            return false;
        }

        if (!preg_match("@^[raw]\\+?b?$@", $mode)) {
            trigger_error(
                "Invalid opening mode : ".$mode.". Use fopen() modes.",
                E_USER_WARNING
            );

            return false;
        }

        $this->_dHandle = @fopen($this->_device, $mode);

        if ($this->_dHandle !== false) {
            stream_set_blocking($this->_dHandle, 0);
            $this->_dState = SERIAL_DEVICE_OPENED;

            return true;
        }

        $this->_dHandle = null;
        trigger_error("Unable to open the device", E_USER_WARNING);

        return false;
    }
public function deviceOpen($mode = "r+b")
    {
        if ($this->_dState === SERIAL_DEVICE_OPENED) {
            trigger_error("The device is already opened", E_USER_NOTICE);

            return true;
        }

        if ($this->_dState === SERIAL_DEVICE_NOTSET) {
            trigger_error(
                "The device must be set before to be open",
                E_USER_WARNING
            );

            return false;
        }

        if (!preg_match("@^[raw]\\+?b?$@", $mode)) {
            trigger_error(
                "Invalid opening mode : ".$mode.". Use fopen() modes.",
                E_USER_WARNING
            );

            return false;
        }

        $this->_dHandle = @fopen($this->_device, $mode);

        if ($this->_dHandle !== false) {
            stream_set_blocking($this->_dHandle, 0);
            $this->_dState = SERIAL_DEVICE_OPENED;

            return true;
        }

        $this->_dHandle = null;
        trigger_error("Unable to open the device", E_USER_WARNING);

        return false;
    }
public function deviceOpen ( $ mode = "r+b" ) { if ( $ this -> _dState === SERIAL_DEVICE_OPENED ) { trigger_error ( "The device is already opened" , E_USER_NOTICE ) ; return true ; } if ( $ this -> _dState === SERIAL_DEVICE_NOTSET ) { trigger_error ( "The device must be set before to be open" , E_USER_WARNING ) ; return false ; } if ( ! preg_match ( "@^[raw]\\+?b?$@" , $ mode ) ) { trigger_error ( "Invalid opening mode : " . $ mode . ". Use fopen() modes." , E_USER_WARNING ) ; return false ; } $ this -> _dHandle = @ fopen ( $ this -> _device , $ mode ) ; if ( $ this -> _dHandle !== false ) { stream_set_blocking ( $ this -> _dHandle , 0 ) ; $ this -> _dState = SERIAL_DEVICE_OPENED ; return true ; } $ this -> _dHandle = null ; trigger_error ( "Unable to open the device" , E_USER_WARNING ) ; return false ; }
Opens the device for reading and/or writing.

@param  string $mode Opening mode : same parameter as fopen()
@return bool
Opens the device for reading and / or writing .