I'm trying to get a web page based serial communication working with an Arduino which is connected to a router running Openwrt, it does work but only when either screen is running or remotely connected via putty, for some reason the php to serial is not starting a session properly? I use ser2net to manage the serial with the following setting
1000:raw:0:/dev/ttyACM0:9600
I have also tried stty with various settings advised on this forum
Update 1
also tried 80:raw:0:/dev/ttyACM0:9600
as setting for ser2net assuming port 80 is web/http port
my php code is
if (isset($_GET['action']))
{
$serial = new phpSerial();
$serial->deviceSet('/dev/ttyACM0');
$serial->confBaudRate(9600);
$serial->confParity('none');
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl('none');
$serial->deviceOpen();
if ($_GET['action'] == "PIN_12_HIGH")
{
$serial->sendMessage("A");
}
if ($_GET['action'] == "PIN_12_LOW")
{
$serial->sendMessage("B");
}
if ($_GET['action'] == "PIN_11_HIGH")
{
$serial->sendMessage("C");
}
if ($_GET['action'] == "PIN_11_LOW")
{
$serial->sendMessage("D");
}
$serial->deviceClose();
}
update 2
if i add sleep(1);
to my php code it seems to solve some of the problems
a few points
Update 3
After finding this helpful post i seem to have discovered a possible solution with no reset hacking needed to the Arduino. Adding cat /dev/ttyACM0 &
to the start up config of the Openwrt router enables serial communication with the Arduino without reseting it on every transmission of data.
problems left:
Update 4
It looks like your PHP is attempting to directly connect to the tty. Where the ser2net is likely already connected to the tty. Only one application at a time can be connected to the tty. Either stop the ser2net or your PHP should connect to the tcp listener of the desired tty as per your ser2net.conf