Download the PHP package microscrap/uart without Composer

On this page you can find all versions of the php package microscrap/uart. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package uart

microscrap/uart — Linux UART / Serial bindings for ScrapyardIO

Docs (production): ScrapyardIO · microscrap/uart 0.7.x

Docs Packagist Version PHP Version Require Requires ext-posi

PHP library that wraps the posi extension (Posi\Termios) plus microscrap/posix FD helpers with global helpers, enums, and data objects. Every helper delegates to a facade class under Microscrap\Bindings\UART.

This is the bindings package — not the native extension. Ecosystem docs: 0.7.x.

Highlights

Requirements

Installation

Confirm ext-posi is loaded:

Composer also pulls microscrap/posix ^0.7.0. Autoloads src/Helpers/uart-serial.php and src/Helpers/uart-termios.php, registering the global uart_* functions.

Usage

Serial I/O is controlled through global helper functions (uart_open, uart_write, uart_read, uart_set_baud_rate, etc.). All helpers delegate to facade classes and are only defined once (function_exists guard).

Enums live under Microscrap\Bindings\UART\Enums — cases are FULLY UPPERCASE. The port handle is Microscrap\Bindings\UART\DataObjects\UARTPort (int $fd, string $path, int $baud).


Example — send a command and read the response


Example — non-standard baud (Linux BOTHER)


Example — manual termios configuration


API Reference

Serial port lifecycle

Helper Facade method Description
uart_open(string $path, BaudRate\|int $baud = BaudRate::B9600) Serial::uartOpen Open and configure a port; returns UARTPort\|null
uart_set_baud_rate(UARTPort $port, BaudRate\|int $baud) Serial::uartSetBaudRate Change baud on an open port
uart_close(UARTPort $port) Serial::uartClose Close the file descriptor; returns 0 or -1
uart_read(UARTPort $port, int $bytes) Serial::uartRead Read up to $bytes bytes; returns string\|false
uart_write(UARTPort $port, string $data) Serial::uartWrite Write $data; returns bytes written
uart_drain(UARTPort $port) Serial::uartDrain Block until TX FIFO is empty (tcdrain)
uart_flush(UARTPort $port, TermiosQueue $queue = TermiosQueue::TCIOFLUSH) Serial::uartFlush Discard queued I/O (tcflush)
uart_flow(UARTPort $port, TermiosFlow $action) Serial::uartFlow Suspend / resume I/O (tcflow)
uart_make_raw(array $termios) Serial::makeRaw Apply cfmakeraw semantics to a termios array

Termios attribute access

Helper Facade method Description
uart_tcgetattr(UARTPort $port) Termios::uartTcgetattr Read current attributes; returns array\|false
uart_tcsetattr(UARTPort $port, array $t, TermiosAction $a = TermiosAction::TCSANOW) Termios::uartTcsetattr Apply attributes; returns 0 or -1
uart_cfsetispeed(array $t, BaudRate $baud) Termios::uartCfsetispeed Set input baud; returns new array\|false
uart_cfsetospeed(array $t, BaudRate $baud) Termios::uartCfsetospeed Set output baud; returns new array\|false
uart_cfgetispeed(array $t) Termios::uartCfgetispeed Decode input baud; returns BaudRate\|null
uart_cfgetospeed(array $t) Termios::uartCfgetospeed Decode output baud; returns BaudRate\|null

UARTPort data object


Termios array format

uart_tcgetattr returns — and uart_tcsetattr / uart_cfset*speed consume — a plain PHP array:


Enum quick reference

BaudRate

B0, B50, B75, B110, B134, B150, B200, B300, B600, B1200, B1800, B2400, B4800, B9600, B19200, B38400, B57600, B115200, B230400, B460800, B500000, B576000, B921600, B1000000, B1152000, B1500000, B2000000, B2500000, B3000000, B3500000, B4000000

Enum values are POSIX speed_t constants. uart_open / uart_set_baud_rate convert cases to numeric rates via the case name (strip leading B).

TermiosAction

Case Value When settings take effect
TCSANOW 0 Immediately
TCSADRAIN 1 After all output is transmitted
TCSAFLUSH 2 After output drained and input discarded

TermiosQueue

Case Value What tcflush discards
TCIFLUSH 0 Received but unread input
TCOFLUSH 1 Written but untransmitted output
TCIOFLUSH 2 Both queues

TermiosFlow

Case Value Effect
TCOOFF 0 Suspend output
TCOON 1 Resume output
TCIOFF 2 Send STOP character to device
TCION 3 Send START character to device

InputFlag — c_iflag bits

IGNBRK, BRKINT, IGNPAR, PARMRK, INPCK, ISTRIP, INLCR, IGNCR, ICRNL, IUCLC, IXON, IXANY, IXOFF, IMAXBEL, IUTF8

OutputFlag — c_oflag bits

OPOST, OLCUC, ONLCR, OCRNL, ONOCR, ONLRET, OFILL, OFDEL

ControlFlag — c_cflag bits

CBAUD, CBAUDEX, CS5, CS6, CS7, CS8, CSTOPB, CREAD, PARENB, PARODD, HUPCL, CLOCAL, CRTSCTS

CSIZE is omitted (same integer as CS8); use CS8->value to clear/set the character-size field.

LocalFlag — c_lflag bits

ISIG, ICANON, XCASE, ECHO, ECHOE, ECHOK, ECHONL, NOFLSH, TOSTOP, ECHOCTL, ECHOPRT, ECHOKE, FLUSHO, PENDIN, IEXTEN, EXTPROC

ControlChar — c_cc indices

VINTR, VQUIT, VERASE, VKILL, VEOF, VTIME, VMIN, VSWTC, VSTART, VSTOP, VSUSP, VEOL, VREPRINT, VDISCARD, VWERASE, VLNEXT, VEOL2


Notes on uart_open defaults

uart_open applies the following configuration automatically:

To override any of these defaults, call uart_tcgetattr, mutate the returned array with the flag enums, and reapply with uart_tcsetattr.

License

MIT. See LICENSE.


All versions of uart with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4|^8.5|^8.6
ext-posi Version ^0.10.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package microscrap/uart contains the following files

Loading the files please wait ...