The Second Order Effect

PHP Serial Class for OSX

by on Nov.18, 2009, under Tech Articles

Below is an archive of my PHP Serial Class page from my old site.

The data below is still valid, viagra 100mg but the project as a whole has been ported to Google Code. Check there for updates.

Added support for OSX to Rémy Sanchez’s PHP Serial class.

Original version


php_serial.class.php.gz (3.7 kB)


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

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).

The class may also change connection parameters for the given serial

The example script:

include "php_serial.class.php";
// Let's start the class
$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)
// Then we need to open it
// 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
// We can change the baud rate
// etc...

Changes in this version.

List of Changes:

  • Added OSX support


Author Rémy Sanche

Thanks Aurélien Derouineau for finding how to open serial ports with

Thanks Alec Avedisyan for help and testing with reading

OSX tweaks added by Rizwan Kassim

copyright under GPL 2 licence

phpserial is free software; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version. For full license text see file COPYING included in the source tarball.

1 Comment for this entry

  • Jim Wright

    Hi, I’m interested in submitting some code changes to the php_serial page on Google, but I’m not sure how to go about doing this. I’ve only been playing with this code for a short while, but I’ve found a number of things that need changing to make it work better on the Mac.

    The google page doesn’t give any way to submit changes, any help would be appreciated. I’m going to be offline a bit during the holidays, but I’ll get the changes to you as soon as I’m able.

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...