Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A php extension for peripheral I/O Serial in Linux (wrapper of c-periphery)

License

NotificationsYou must be signed in to change notification settings

1nv1/php-periphery-serial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A php extension for peripheral I/O Serial in GNU/Linux.

Introduction

The goal of this project is build a wrapper (serial I/O) ofc-peripherylibrary.

Warning

This project really has two goal, the first is create a wrapper and the secondis learn about php extensions. It's my first project around this.

Right now I uploaded to sourceforge two compilations of the extension. One isfor 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 thislink.

Download

You can download the compiled library in thesourceforge 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-serialrequire_oncedirname(__FILE__).$relative_path_to."/class/Periphery.php";// Create an instance$pb =newPeriphery\Serial();// Yo can see the version of c-periphery embeddedecho"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 {echoPHP_EOL; }// You expects 30 bytes with a 2 senconds of timeoutecho"Close:".($pb->close() ?'yes' :'no').PHP_EOL;

License

php-periphery-serial is MIT licensed. See the includedLICENSE file.

About

A php extension for peripheral I/O Serial in Linux (wrapper of c-periphery)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp