Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #32

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
{
"name": "hyperthese/php-serial",
"name": "zzepish/php-serial",
"description": "Multi-platform serial port access convenience class",
"license": "GNU GPLv2",
"license": "GPL-3.0-only",
"authors": [
{
"name": "Rémy Sanchez",
"email": "[email protected]"
}
],
"minimum-stability": "stable",
"autoload": {
"classmap": ["src/"]
},
"extra": {
"branch-alias": {
"dev-develop": "1.0.x-dev"
"psr-4": {
"PhpSerial\\": "src/"
}
}
}
102 changes: 0 additions & 102 deletions examples/VS421CPNTA.php

This file was deleted.

17 changes: 11 additions & 6 deletions examples/dummy.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
<?php
include 'PhpSerial.php';
require_once __DIR__ . '/../vendor/autoload.php';

use \PhpSerial\PhpSerial;
use \PhpSerial\Interfaces\BaudInterface;
use \PhpSerial\Interfaces\ParityInterface;
use \PhpSerial\Interfaces\FlowControlInterface;

// Let's start the class
$serial = new PhpSerial;
$serial = new PhpSerial();

// First we must specify the device. This works on both linux and windows (if
// your linux serial device is /dev/ttyS0 for COM1, etc)
$serial->deviceSet("COM1");

// We can change the baud rate, parity, length, stop bits, flow control
$serial->confBaudRate(2400);
$serial->confParity("none");
$serial->confBaudRate(BaudInterface::RATE_2400);
$serial->confParity(ParityInterface::NONE);
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("none");
$serial->confFlowControl(FlowControlInterface::NONE);

// Then we need to open it
$serial->deviceOpen();
Expand All @@ -28,7 +33,7 @@
$serial->deviceClose();

// We can change the baud rate
$serial->confBaudRate(2400);
$serial->confBaudRate(BaudInterface::RATE_2400);

// etc...
//
Expand Down
11 changes: 7 additions & 4 deletions examples/sms.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?php
include 'PhpSerial.php';
require_once __DIR__ . '/../vendor/autoload.php';

use \PhpSerial\PhpSerial;
use \PhpSerial\Interfaces\BaudInterface;

// Let's start the class
$serial = new PhpSerial;
$serial = new PhpSerial();

// First we must specify the device. This works on both linux and windows (if
// your linux serial device is /dev/ttyS0 for COM1, etc)
Expand All @@ -15,10 +18,10 @@
$serial->deviceOpen('w+');

// We may need to return if nothing happens for 10 seconds
stream_set_timeout($serial->_dHandle, 10);
stream_set_timeout($serial->dHandle, 10);

// We can change the baud rate
$serial->confBaudRate(9600);
$serial->confBaudRate(BaudInterface::RATE_9600);

// SMS inbox query - mode command and list command
$serial->sendMessage("AT",1);
Expand Down
19 changes: 19 additions & 0 deletions src/Interfaces/BaudInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace PhpSerial\Interfaces;

interface BaudInterface
{
public const RATE_110 = 110;
public const RATE_150 = 150;
public const RATE_300 = 300;
public const RATE_600 = 600;
public const RATE_1200 = 1200;
public const RATE_2400 = 2400;
public const RATE_4800 = 4800;
public const RATE_9600 = 9600;
public const RATE_19200 = 19200;
public const RATE_38400 = 38400;
public const RATE_57600 = 57600;
public const RATE_115200 = 115200;
}
10 changes: 10 additions & 0 deletions src/Interfaces/FlowControlInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace PhpSerial\Interfaces;

class FlowControlInterface
{
public const NONE = 'none';
public const XON_XOFF = 'xon/xoff';
public const RST_CTS = 'rts/cts';
}
10 changes: 10 additions & 0 deletions src/Interfaces/ParityInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace PhpSerial\Interfaces;

interface ParityInterface
{
public const ODD = 'odd';
public const EVEN = 'even';
public const NONE = 'none';
}
Loading