Skip to content

Commit 90c3d39

Browse files
committed
Updates
1 parent 77721ef commit 90c3d39

File tree

17 files changed

+67
-63
lines changed

17 files changed

+67
-63
lines changed

src/Commands/Listen.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Amp\Socket\InternetAddress;
1010
use Amp\Websocket\Server\Rfc6455Acceptor;
1111
use Amp\Websocket\Server\Websocket;
12-
use Flat3\RevPi\JsonRpc\ClientHandler;
12+
use Flat3\RevPi\Rpc\ClientHandler;
1313
use Illuminate\Console\Command;
1414
use Psr\Log\LoggerInterface;
1515
use Revolt\EventLoop;

src/Hardware/Remote/RemoteCharacterDevice.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use Flat3\RevPi\Constants;
88
use Flat3\RevPi\Interfaces\Hardware\Stream;
9-
use Flat3\RevPi\JsonRpc\JsonRpcDevice;
9+
use Flat3\RevPi\Rpc\RpcDevice;
1010
use Revolt\EventLoop;
1111

1212
abstract class RemoteCharacterDevice extends RemoteDevice implements Stream
@@ -17,7 +17,7 @@ abstract class RemoteCharacterDevice extends RemoteDevice implements Stream
1717
/** @var resource */
1818
protected mixed $remote;
1919

20-
public function __construct(JsonRpcDevice $peer)
20+
public function __construct(RpcDevice $peer)
2121
{
2222
parent::__construct($peer);
2323

@@ -28,6 +28,14 @@ public function __construct(JsonRpcDevice $peer)
2828
stream_set_blocking($this->remote, false);
2929
}
3030

31+
public function close(): int
32+
{
33+
fclose($this->remote);
34+
fclose($this->local);
35+
36+
return parent::close();
37+
}
38+
3139
public function fdopen(): mixed
3240
{
3341
$this->device->request('fdopen')->await();

src/Hardware/Remote/RemoteDevice.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
use Amp\Websocket\WebsocketClient;
88
use Flat3\RevPi\Interfaces\Hardware\Device;
99
use Flat3\RevPi\Interfaces\Hardware\Ioctl;
10-
use Flat3\RevPi\JsonRpc\JsonRpcDevice;
10+
use Flat3\RevPi\Rpc\RpcDevice;
1111

1212
use function Amp\async;
1313

1414
abstract class RemoteDevice implements Device, Ioctl
1515
{
16-
public function __construct(protected JsonRpcDevice $device) {}
16+
public function __construct(protected RpcDevice $device) {}
1717

1818
public function socket(WebsocketClient $websocket): void
1919
{

src/Interfaces/Module.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public function monitor(string $variable, Monitor $monitor, callable $callback):
4646
/**
4747
* Get a serial port instance for communication on the specified device path.
4848
*
49-
* @param string $devicePath The path to the serial device (e.g. "/dev/ttyS0").
49+
* @param string $devicePath The path to the serial device (e.g. "/dev/ttyRS485").
5050
* @return SerialPort The serial port instance.
5151
*/
52-
public function getSerialPort(string $devicePath): SerialPort;
52+
public function getSerialPort(string $devicePath = '/dev/ttyRS485'): SerialPort;
5353
}

src/Interfaces/SerialPort.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public function write(string $data): void;
137137
*
138138
* @param QueueSelector $selector Selector specifying which buffers to flush.
139139
*/
140-
public function flush(QueueSelector $selector): void;
140+
public function flush(QueueSelector $selector = QueueSelector::Both): void;
141141

142142
/**
143143
* Wait until all output written to the serial port has been transmitted.

src/Modules/Module.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function getProcessImage(): ProcessImage
3232
return $this->processImage;
3333
}
3434

35-
public function getSerialPort(string $devicePath): SerialPort
35+
public function getSerialPort(string $devicePath = '/dev/ttyRS485'): SerialPort
3636
{
3737
return app(SerialPort::class, ['devicePath' => $devicePath]);
3838
}

src/Modules/Remote.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getProcessImage(): ProcessImage
4040
return $this->processImage;
4141
}
4242

43-
public function getSerialPort(string $devicePath): SerialPort
43+
public function getSerialPort(string $devicePath = '/dev/ttyRS485'): SerialPort
4444
{
4545
$terminal = app(RemoteTerminalDevice::class);
4646
$terminal->socket(connect($this->handshake->withQueryParameter('device', 'terminal')));

src/Modules/Virtual.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function getLed(LedPosition $position): Led
1818
return app(VirtualLed::class, ['position' => $position]);
1919
}
2020

21-
public function getSerialPort(string $devicePath): SerialPort
21+
public function getSerialPort(string $devicePath = '/dev/ttyRS485'): SerialPort
2222
{
2323
return app(SerialPort::class, ['device' => app(VirtualTerminalDevice::class)]);
2424
}

src/RevolutionPi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function led(LedPosition $position): Led
6464
/**
6565
* Get the SerialPort object for communication via a specific device path.
6666
*/
67-
public function serialPort(string $devicePath = '/dev/ttyRS485-0'): SerialPort
67+
public function serialPort(string $devicePath = '/dev/ttyRS485'): SerialPort
6868
{
6969
return $this->module()->getSerialPort($devicePath);
7070
}

src/JsonRpc/ClientHandler.php renamed to src/Rpc/ClientHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Flat3\RevPi\JsonRpc;
5+
namespace Flat3\RevPi\Rpc;
66

77
use Amp\Http\Server\Request;
88
use Amp\Http\Server\Response;
@@ -22,7 +22,7 @@ public function handleClient(WebsocketClient $client, Request $request, Response
2222
default => throw new NotSupportedException,
2323
};
2424

25-
$handler = app(JsonRpcDevice::class);
25+
$handler = app(RpcDevice::class);
2626
$handler->setDevice($target);
2727

2828
$handler->attachSocket($client);

0 commit comments

Comments
 (0)