Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.
/ php-serial Public archive

PHP class utilizing Direct IO to interact with a RS232 serial port

License

Notifications You must be signed in to change notification settings

mdlayher/php-serial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

serial

PHP class utilizing Direct IO to interact with a RS232 serial port.

Installation

To install using Composer, add "mdlayher/serial": "dev-master" to the require section of your composer.json.

Usage

Point the class to your serial RS232 device file location. Options may be set once a connection is established.

<?php
	// serial demo
	require_once __DIR__ . "/vendor/autoload.php";
	use \serial\serial as serial;

	// Open serial connection
	$serial = new serial("/dev/pts/1");

	// Set connection options
	$options = array(
		"baud" => 38400,
		"bits" => 8,
		"stop" => 1,
		"parity" => 0,
	);
	$serial->set_options($options);

	// Write data, read response (in this case, OBD-II)
	$serial->write("AT RV\r");
	printf("res: %s\n", $serial->read());

About

PHP class utilizing Direct IO to interact with a RS232 serial port

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages