cronox / serial-php
串口与PHP之间通信的库
v1.0.1
2019-05-21 11:24 UTC
Requires
- php: ^7.2
This package is auto-updated.
Last update: 2024-09-21 23:09:26 UTC
README
将以下行添加到您的 composer.json
文件中
"cronox/serial-php": "^1.0"
或者运行
composer require cronox/serial-php
简单示例
$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; }