I'm trying to send data to my Arduino as fast as possible with PHP.
The actual speed doesnt matter. Faster is just better.
My problem is unless I have a 50 - 100ms sleep, the serial buffer overflows.
Instead of having a fixed delay I decided to add a ACK packet so it delays as little as possible.
I cannot seem to receive the packet though.
I've tried using both serproxy and a serial class (on phpclasses.org) for talking to serial.
Neither will give me the ACK byte though. I've tried sending 0x01 and 0xFF.
I need the bidirectional data because I've got some sensors in the mail which need to send data back to the PHP script.
Don’t know exactely what you are trying to do, but if you have Visual Basic writing a program that communicates with the Arduino is pretty simple. And as for using php, you could use MS Winsock in VB and fsockopen() in php to communicate between Visual Basic program and php.
Perhaps not what you are looking for, but I find it works quite well. I can for example use my Arduino read sensors at home (ultrasound, simple on/off switches on doors) and use the VB program to monitor inputs and log whenever something happens. Whenever someone enters your webside (which can be hosted remotely, because of the TCP/IP-connection used to get data from the VB-program), the php-script connects to your server running VB+Arduino and fetches info like logs for doors, movement inside your room/apartment, whatever.
If you make a php-script that connects to the Arduino directly, that’s cool, but you loose real-time monitoring of what is happening on your inputs. Unless you are planning on making a php-daemon, you will only be able to read the inputs of the Arduino at the moment the webpage (php-script) is loaded.
Another pretty cool thing one could implement is scheduling. Perhaps I want my lights to turn off at 08:30 when i am sure I am at work, and turn back on at 16:00 right before I get home. Using VB (or other compilable programming language) as a backend, and a php-driven website as a front-end, you could use the website to create schedules for your backend program.
Ok, probably a pretty sucky reply but it’s 18:30 in the evening, I’ve been at work for almost 10 hours and it looks like I’ll be here for another couple of hours.
I'm using Linux so interfacing PHP to the serial port is relatively easy.
Apparently its next to impossible on Windows.
And I am using a daemon. PHP isnt just a web language.
My problem is receiving the ACK packet the Arduino is sending.
I'm either getting nonsense or nothing with multiple different methods.
Oh, cool! =) I know one can run php as a daemon, I just have this mental block'ish thing about actually doing so. At least if we are talking about a system that needs to stay up 24/7. But hey, php is pretty versatile and damn hot, so if you keep your shit straight you could probably write pretty complex console-apps.
Is it just these ACK-packages that aren't getting through? First thing that comes to mind is your setup.. I'm not a linux-guru, but you read the serial port device as a file, right? F.ex. "tail /dev/whatevertheserialportiscalled".. Do you know for certain that your baudrate, paritybit, all that stuff is set to what the Arduino needs?
Just my 2 cents.