1. Go to this page and download the library: Download gregorj/serial-port library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gregorj / serial-port example snippets
use GregorJ\SerialPort\Commands\BasicStringCommand;
use GregorJ\SerialPort\StreamCommunication;
use GregorJ\SerialPort\TcpStream;
$stream = new TcpStream('127.0.0.1', 5000);
$communication = new StreamCommunication($stream);
$command = new BasicStringCommand('HELLO', "\n", "\n");
$response = $command->invoke($communication);
echo $response?->get('response');
use GregorJ\SerialPort\Commands\BasicStringCommand;
use GregorJ\SerialPort\CurlTransport;
use GregorJ\SerialPort\HttpCommunication;
$communication = new HttpCommunication(
new CurlTransport(),
'https://example.com/query',
'ttyUSB0',
HttpCommunication::DEVICE_TYPE_WIRED
);
$command = new BasicStringCommand('HELLO', "\n", "\n");
$response = $command->invoke($communication);
echo $response?->get('response');
use GregorJ\SerialPort\Commands\BasicVoidCommand;
use GregorJ\SerialPort\StreamCommunication;
use GregorJ\SerialPort\TcpStream;
$communication = new StreamCommunication(new TcpStream('127.0.0.1', 5000));
$command = new BasicVoidCommand('AT+RESET', "\r\n");
$command->invoke($communication);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.