Fix serial tty setup, include matches in prompt event
This commit is contained in:
parent
3546cfde30
commit
fe25005107
@ -62,13 +62,13 @@ class LineBufferedDuplexStream implements ReadableStreamInterface, WritableStrea
|
|||||||
|
|
||||||
// Check if the buffer matches the prompt pattern
|
// Check if the buffer matches the prompt pattern
|
||||||
if ($this->promptPattern !== null) {
|
if ($this->promptPattern !== null) {
|
||||||
if (preg_match($this->promptPattern, $this->buffer)) {
|
if (preg_match($this->promptPattern, $this->buffer, $matches)) {
|
||||||
$this->buffer = preg_replace($this->promptPattern, '', $this->buffer);
|
$this->buffer = preg_replace($this->promptPattern, '', $this->buffer);
|
||||||
if ($this->bufferOutput) {
|
if ($this->bufferOutput) {
|
||||||
$this->emit(self::EVT_OUTPUT, [$this->output]);
|
$this->emit(self::EVT_OUTPUT, [$this->output]);
|
||||||
$this->output = [];
|
$this->output = [];
|
||||||
}
|
}
|
||||||
$this->emit(self::EVT_PROMPT, []);
|
$this->emit(self::EVT_PROMPT, [ $matches ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class SerialFactory
|
|||||||
$deferred = new Deferred();
|
$deferred = new Deferred();
|
||||||
|
|
||||||
Loop::futureTick(static function () use ($device, $baud, $bits, $parity, $stop, $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 cbreak min 0 time 0";
|
$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";
|
//echo $cmd."\n";
|
||||||
exec($cmd);
|
exec($cmd);
|
||||||
$fd = fopen($device, "a+");
|
$fd = fopen($device, "a+");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user