PHP Serial Communication NOT working

Ya, Hi.

So my PHP Serial communication code isn't working UNLESS the Arduino IDE's Serial Monitor is opened. Same goes for the terminal commands for serial.

I looked into it for a few days, the closest thing people had for an answer is that since the monitor is closed, the Arduino resets every time the serial communication is opened and doesn't have time and doesn't have time to read what was sent after rebooting. Although logically it should be able to do so if I put a delay between the Serial open and the serial write lines, but still nothing.

So I went for the Autoreset option, I got a 10uF capacitor and connected it between the GND and the reset pin (I am using Arduino Uno). Arduino did stop resetting every time I use the PHP code, but it still doesn't read/act based on what is sent (same code works when Serial Monitor is open).

I am loosing it and I have no idea what's wrong :D Help? :D

Are you running a local/web server with an Arduino connected, or via a Yun, what is your setup?

Using USB Serial and a local host (Apache through XAMPP) and I am on a Mac.

You could delve into the IDE source and find what it does to reset the Arduino.

Or maybe put your Arduino into a loop until you receive a certain string from the PHP script. Your PHP can connect and send the string with each retry separated by a delay. Once the communication is finished the Arduino can continue looking for the connect string.

The arduino DID stop the autoreset when I use the PHP code. But if the Serial Monitor isn't open the page will keep on loading and hangs at the serial open statement.

if the arduino receives anything a relay acts, nothing happens.

Generally speaking concerning PCs, only one application at a time can be connected to a specific com port. You probably cannot use the arduino virtual com port with php and the serial monitor at the same time.

I thought so as well, funny enough.. it's the ONLY way either PHP or terminal work....

Anyone? :smiley:

So I think I found out what's wrong.

Someone suggested that the Serial Monitor opens the port itself, so I needed to do the same with PHP.

I tried this on terminal

screen /dev/tty.usbmodem411 9600

It made a terminal screen for the serial communication (simulated a serial monitor) and worked in sending info to the arduino without the actual Serial Monitor running.

Now I need to do it with PHP, so this is what I tried on PHP

exec("screen /dev/tty.usbmodem411 9600");

It's not working, the page still hangs like before, which made me thing the function isn't executing on terminal.

Any suggestions? :D

Now I made a Processing application that does everything when executed, but PHP's exec() isn't working with it.

I think there is some serious issues with "Permissions" when it comes to XAMPP -_-

Check line 17 of your code.

I didn't even post my code?

Shamy:
I didn’t even post my code?

Exactly my point

[quote author=James C4S link=topic=229625.msg1659788#msg1659788 date=1396301112]

Shamy: I didn't even post my code?

Exactly my point [/quote]

Still cannot figure out why smart aleck replies are thought to be in any way helpful by a subset of this forum's readership. Particularly when they go two levels deep.

JohnHoward: [quote author=James C4S link=topic=229625.msg1659788#msg1659788 date=1396301112]

Shamy: I didn't even post my code?

Exactly my point

Still cannot figure out why smart aleck replies are thought to be in any way helpful by a subset of this forum's readership. Particularly when they go two levels deep. [/quote] Come on back after you've made more than 5000 posts, trying to help people that can't be bothered to post code, but still whine for help.

PaulS: whine for help.

Excuse me for ever thinking I was directing my question to people who know exactly 4 lines of code. Apparently I overestimated your intelligence.

I simply came back to post that I fixed it, all I had to do is use Linux not Mac and it worked just fine.

As for you reply, if you think coming to a technical forum asking for help for something they have been stuck with for the past couple of days "whining" then you're full of it, get off your horse. As you can see problem got solved without your help, so the sun doesn't revolve around you "mad genius".