*/ public function open(string $device, int $baud = 9600, int $bits = 8, Parity $parity = Parity::NONE, int $stop = 1): PromiseInterface { $deferred = new Deferred(); Loop::futureTick(static function () use ($device, $baud, $bits, $parity, $stop, $deferred) { $cmd = "stty -F ".escapeshellarg($device)." ".$baud." ".$parity->value." ".escapeshellarg("cs".$bits)." ".($stop==1?"-cstopb":"cstopb")." -echo -icrnl cbreak min 0 time 0"; //echo $cmd."\n"; exec($cmd); $fd = fopen($device, "a+"); $stream = new DuplexResourceStream($fd); $deferred->resolve($stream); }); return $deferred->promise(); } }