Hello Guys,
I'm writing an application to communicate to a Lantronic Xport device… The problem is having a issue currently issuing commands to the device without having a delay between the send and the read. I’m not sure what I’m doing wrong but it’s starting to drive insane!
I’m establishing the connection using:
$phost=”192.168.1.10”;
$pport=’’10001”;
$fp = @fsockopen("tcp://" . $phost, $pport, $errno, $errstr, 15);
I have a function like this to write to the socket:
function Send($BusString){
if ($this->psocketconnected){
$TT ='';
foreach ($BusString as $BusStringValue) {
$TT .= chr($BusStringValue);
}
fwrite($this->psocket, $TT);
fflush($this->psocket);
return True;
}
return False;
}
And a function like this to read :
function Get(){
sleep(1); //< -- here is my problem…
if ($this->psocketconnected){
$cbyte = '';
$cbyte = fread($this->psocket, 1024);
return $cbyte;
}
}
Now here is my problem, this is working but in order to make it work I had to add the sleep(1); to my read function. As you can imagine, sending and reading multiple values just make the session/page time out (30sec execution time).
I have written another application to try to debug this and I have no problem sending and receiving values from the device and there is no sleep or delay involved.
The vales that I am writing look like this (hex):
01 51 70 C2 02 48 4E 43 05 03 67 04 FF FF 01 70 C2 04 FF FF
And a response would look like this:
01 70 51 C2 02 48 4E 43 40 3A 31 33 30 03 70 FF FF
Would anyone have any ideas to what could be the problem?
Thanks