php-serial

来源:互联网 发布:淘宝 军品 编辑:程序博客网 时间:2024/05/18 20:33
http://code.google.com/p/php-serial/
 
 
php-serial
PHP Class to support serial port access (and various other serial device drivers)
Project HomeDownloadsWiki Issues Source
Summary  People
 
Project Information
  • Project feeds
  • Code license
  • GNU GPL v2
  • Labels
    php,serial,osx,linux,darwin
Members
    rizw...@gmail.com,remy.san...@hyperthese.net
  • 1 committer

This PHP class can be used to communicate with a serial port under Linux, OSX or Windows.

Description

Gives serial access to PHP under linux, OSX and Windows (write-only under Windows).

This class can be used to communicate with a serial port under Linux, OSX or Windows.

It takes the path (like "/dev/ttyS0" for linux or "COM1" for windows) of serial device and checks whether it is valid before opening a connection to it.

Once the connection is opened, it can send data to the serial port, and read answers (reading is only implemented for Linux or OSX).

The class may also change connection parameters for the given serial device.

Sample Code

<?php deviceSet("COM1");   // Then we need to open it  $serial->deviceOpen();   // To write into  $serial->sendMessage("Hello !");   // Or to read from  $read = $serial->readPort();   // If you want to change the configuration, the device must be closed  $serial->deviceClose();   // We can change the baud rate  $serial->confBaudRate(2400);   // etc...  ?> 

Older details available at : http://www.phpclasses.org/browse/package/3679.html http://www.geekymedia.com/phpserial.html