i would greatly appreciate any help here on three issues:
I'm trying to get a PHP/HTML script talking with my arduino. I'd like to control the board remotely.
the following script is able to SET dev/ttyUSB0, but can't seem to open it in the next line.
<?php
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)
$serial->deviceSet("/dev/ttyUSB0");
// 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(9600);
// etc...
?>
i also messed around with udev to try and create a fixed device name, (arduino), so i don't have to keep chmod'ing tyUSB0.
i saved the above line in 99-udevmonitor.rules -- no luck
it seems that the arduino and a processing sketch can't both be connected to ttyUSB0 at the same time? Shure would be easier to edit the sketch and the PHP script together? any suggestions?
$serial->confBaudRate(9600); //Baud rate: 9600
$serial->confParity("none"); //Parity (this is the "N" in "8-N-1")
$serial->confCharacterLength(8); //Character length (this is the "8" in "8-N-1")
$serial->confStopBits(1); //Stop bits (this is the "1" in "8-N-1")
I've got basically the same set up using a LAMP stack on OSX. It also didn't work first time, so I changed the device name trying several different formats, and for "no reason", it decided to start working using the original name format. Not exactly confidence inspiring, but it makes the process of scripting Arduino and sending and receiving real-time data under php, nice and tidy and cuts out processing as the middle man between server and hardware.
When the Apache server is turned off, then back on again - the script gets stuck waiting for localhost.
The only solution I have found so far, is to fire up the Arduino IDE, turn on the serial monitor, then close the IDE. Then, the script works fine again.
I've tried it several times, and it's the same every time.