kba-team / serial-port
Connect to serial ports using TCP connections.
Installs: 18
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
pkg:composer/kba-team/serial-port
Requires
- php: ^7.2
- ext-json: *
- ext-sockets: *
Requires (Dev)
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2025-10-17 22:17:41 UTC
README
PHP class \kbATeam\SerialPort\SerialPort to connect to serial ports using streams. Nothing more. Only socket (TCP) streams are implemented at the moment.
You need to create classes implementing \kbATeam\SerialPort\Interfaces\Communication\Command, \kbATeam\SerialPort\Interfaces\Communication\Container and \kbATeam\SerialPort\Interfaces\Communication\Value. The implementations of these interfaces depend on the device you want to communicate with.
Usage
Use pySerial to map a serial device to a TCP port.
Use Streams\Socket to create a connection to a SerialPort use SerialPort->invoke() to invoke a Communication\Command and get either NULL or a Communication\Container containing at least one Communication\Value.
A Communication\Command instance is a string sent to a SerialPort instance. The SerialPort instance invokes the Communication\Command using its Stream instance.
Your implementation of Communication\Command needs to define how to read the string returned by the device and either return a Communication\Container containing at least one Communication\Value, or NULL.