cronox/serial-php

Library for communication between serial port and PHP

v1.0.1 2019-05-21 11:24 UTC

This package is auto-updated.

Last update: 2024-05-21 22:29:17 UTC


README

add this line to your composer.json file:

"cronox/serial-php": "^1.0"

or run

composer require cronox/serial-php

A Simple Example

$phone = '321321321';
$message = 'Test SMS'
try {
    $serial = new \Cronox\SerialPHP\SerialPHP();
    $serial->setSerialPort('/dev/ttyS0');
    $serial->openSerialPort();
    $serial->setBaudRate(9600);
    $serial->send('AT', 2);
    $serial->send('AT+CMGF=1', 2);
    $serial->send('AT+CMGS="'.$phone.'"', 2);
    $serial->send($message.chr(26), 4);
    return $serial->read();
} catch (\Exception $exception) {
    throw $exception;
}