

GitHub - 1nv1/php-periphery-serial: A php extension for peripheral I/O Serial in...
source link: https://github.com/1nv1/php-periphery-serial
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

php-periphery-serial
A php extension for peripheral I/O Serial in GNU/Linux.
Introduction
The goal of this project is build a wrapper (serial I/O) of c-periphery library.
Warning
This project really has two goal, the first is create a wrapper and the second is learn about php extensions. It's my first project around this.
Right now I uploaded to sourceforge two compilations of the extension. One is for x86_64 target system and the other was build on a x86. The last one was tested with real electronics hardware without problems.
Next steps
- Public attributes
- Testing arguments
- Test again over real hardware (x86/x86_64)
- Documentation of class
- I will keep uploading compiled versions
- Errors support
Documentation
You can access to documentation to class in this link.
Download
You can download the compiled library in the sourceforge page.
Build
Previous, do you need install the developer package of ^PHP7x. In Fedora:
# dnf install php-devel
Now, clone the repo:
$ git clone --recurse-submodules -j8 https://github.com/1nv1/php-periphery-serial.git
To compile, you need to do these steps
$ phpize $ ./configure --enable-periphery_serial $ make # make install
Do you need clean the project?
$ make clean && phpize --clean
Example
This is a simple example:
<?php // Class for use periphery-serial require_once dirname(__FILE__).$relative_path_to."/class/Periphery.php"; // Create an instance $pb = new Periphery\Serial(); // Yo can see the version of c-periphery embedded echo "Version: ".$pb->version().PHP_EOL; // Now, open the serial port: path to device and baudrate $res = $pb->open("/dev/ttyUSB0", 38400) ? 'yes' : 'no'; if ($res == 'no') { echo "Error at open!".PHP_EOL; die(); } echo "Open: yes".PHP_EOL; echo "Flush...".PHP_EOL; $pb->flush(); // Take the "string" to send and convert it in array $send = str_split("RP"); echo "Write: ".$pb->write($send, 2).PHP_EOL; echo "Read: "; // Do you need wait 30 bytes response with a 2 senconds of timeout? $res = $pb->read(30, 2000); if (!empty($res)) { var_dump($res); } else { echo PHP_EOL; } // You expects 30 bytes with a 2 senconds of timeout echo "Close: ".($pb->close() ? 'yes' : 'no').PHP_EOL;
License
php-periphery-serial is MIT licensed. See the included LICENSE file.
Recommend
-
78
README.md
-
4
Designing with Peripheral Vision
-
7
Looking for autoplay?Choose whether videos automatically play next.Got it...
-
7
How A Long-Lost Peripheral Would Have Transformed A Game Boy Into A Personal Computer Top Videos The on-set vocal performance of David Prowse is very different from the Darth Vader voice we know s...
-
8
Inputs Of Interest: Marsback M1 Is A Portable Party Peripheral Again, let’s just get this out of the way up front: I got this lovely little 75% keyboard for free from a gaming accessories company call...
-
4
-
12
SPI: The serial peripheral interface139,553 viewsSep 4, 2021 More 6502 computer info:
-
5
Speaker.app / zenRTC / Phantom Server NOTE: This program is a work in progress, the console may be spammy, and it may not work at all, however, a stable version should be running here.
-
6
The Direct Benefits of Peripheral SkillsBoost your job prospects by stepping out of career tunnel vision.
-
11
The future comes calling — William Gibson’s novel comes to vivid life in first teaser for The Peripheral Prime Video series is the latest from Westworld c...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK