themainframe / serially
Talk to serial devices in PHP
Installs: 19
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/themainframe/serially
Requires
- psr/log: 1.0.*@dev
This package is not auto-updated.
Last update: 2025-10-25 20:05:49 UTC
README
Talk to serial devices in PHP from various* platforms.
Getting It
Get Composer. Make your project require Serially.
composer require themainframe/serially dev-master
Examples
The ConnectionManager class enables you to write platform-portable code against Serially by abstracting the platform detection process away from your code.
The getConnection method returns an connection instance implementing ConnectionInterface suitable for the current platform.
$manager = new ConnectionManager;
$connection = $manager->getConnection('/dev/ttyS0');
$connection->writeLine('Hello from PHP');
Logging
Debugging serial devices and the communication between them can be difficult. Serially logs to a PSR-3-conformant LoggerInterface to make the process easier.
// $myLogger implements LoggerInterface
// Connections created with this manager will be logged to $myLogger
$manager->setLogger($myLogger);
Limitations
Reading bytes from serial ports is a challenge in PHP. Depending on the platform, you may observe
that data received before readLine() or readByte() is called may or may not be available.
Platform agility is a work-in-progress. The PlatformSpecific namespace contains platform-specific connection implementations (of ConnectionInterface) for Mac OS X (Darwin) and Linux. A Windows one may emerge soon.
Attributions & Thanks
- Heavilly inspired by rubberneck's php-serial.