12-14-2009 07:11 PM
Hello, i´ve a simply led.
I would control value of led over sockets using PHP programming language. My question is, where are documentation and examples? I found many examples between 2 or more Labview applications but not in PHP. I don´t found documentation that explins information to send to Labview application from PHP sockets...
It´s possible?
Thanks!
12-14-2009 09:00 PM
12-15-2009 03:33 AM - edited 12-15-2009 03:39 AM
Yes i know this. I would implement led management over sockets TCP because my version of Labview (8.5) don´t support WebServices, but i don´t found documentation for this.
You said that i have to implement protocol, i will investigate this.
Thanks.
12-15-2009 03:43 AM
01-03-2010 06:43 PM
Hello, in this moment i did an example that read value of string labview from PHP.
Now, i need send data from php tolabview but i don´t could makethis... I´ve this schema on labview:
In PHP i´ve this:
$socket = socket_create(AF_INET, SOCK_STREAM, 0);
socket_bind($socket, "127.0.0.1");
socket_connect($socket, "127.0.0.1", 4005);
$msg = "Test Message";
$sock_data = socket_write($socket, $msg, strlen($msg));
$res = "Data sended with response $sock_data.";
echo $res;
Any idea?
Thanks.
01-05-2010 06:39 PM
Hello, it work! I changed the number of bytes that TCP READ read. When string is equals "a", it set led to true:
PHP Code:
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_bind($socket, "127.0.0.1");
socket_connect($socket, "127.0.0.1", 4005);
if(strcmp($data,"")==0){
$msg = "Default msg";
} else {
$msg = $data;
}
$size = strlen($msg);
$sock_data = socket_write($socket, $msg, strlen($msg));
$res = "Data sended ($size) with response $sock_data.";
But now, a get this error when TCP close:
But i don´t understand because i´ve defined my IP in VI Server:Machine Access .
Any idea?
02-21-2010 05:33 PM
Has you found a solution to solve this error? I am very interested in your VI because I am doing something similar
Thanks
02-21-2010 07:14 PM
Hello Islero, you need to do a VI as image of my last post and you can use the PHP code.
Just change lenght of the String received on VI, for example if you send a string with "a" change value 16 to 1.
02-22-2010 06:10 PM
07-06-2010 04:49 PM
Hey Pedro,
I'm using Apache, PHP 5.3 and LabVIEW 2009. I'm doing mostly the same thing you are and have it working, but then again you do too. Error 66 means the client closed the connection, which is what you want. So in your LabVIEW code, you can watch for error 66 and filter it out because it means everything worked well (the PHP script called socket_close or exited).
As a sidebar, does anyone have any good architectural ideas for a communication scheme between a webserver and LabVIEW? Right now I'm using session IDs and a socket communication protocol that goes something like this:
Thanks,
Mac