NYCPHP Meetup

NYPHP.org

[nycphp-talk] Serial communication in Mac OS X

Rolan Yang rolan at omnistep.com
Thu Apr 17 17:41:28 EDT 2008


Corey Fogarty wrote:
> Hi All,
>
> I am trying to connect to /dev/tty.USA28Xb2P1.1 which is a Keyspan USB 
> to Serial adapter. I have had success using the screen utility, 
> #screen /dev/tty.USA28Xb2P1.1 but I would like to use PHP to create a 
> web interface to a microcontroller.
>

Hi Cory,

With what device are you trying to communicate?  I log the status and 
usage of my gas furnace with a small photocell wired to a A-D converter 
board which outputs RS232 to a Serial->USB converter then to my "server 
in the closet", which stores all the data to MySQL through a php script. 
The serial to usb converter, I believe, uses the "Prolific" chipset.  I 
also had some trouble speaking directly to the serial port. In the end, 
I gave up and just wrote a C program to grab the data and output to 
stdout. The PHP script captured data continuously with a:

<?php
while (1) {
$data=trim(`./checkfurnace 20 1 1`);
// write to sqldb
sleep(9);
}
?>

I also have a Lacrosse weather station on the roof that sends data 
through a serial cable -> USB converter -> the same server in the 
closet, and it logs data the same way.

Good luck. How are those robots coming along?

~Rolan










More information about the talk mailing list