I’m new in php. For now I can read the code (not good), and can write a little bit.
I have several weight scales. From first one I can read the weight with this script:
JavaScript
x
// host and port to connect to
$host = "10.0.0.119";
$port = 3400;
// connect to the port
$fp = fsockopen($host, $port, $errno, $errstr);
// don't die
set_time_limit(0);
// if connection not successfull, display error
if (!$fp)
{
die("no connection");
}
else
{
// connection successfull, listen for data (1024 bytes by default)
$got = fgets($fp);
// display the data
echo $got;
}
fclose($fp);
Here is output from socket listener:
And here is from browser:
But from other scale I can’t read anything. Here is the output from socket terminal: (see pic 3 )
I think the problem is it in the php script, but I cant find it. If someone can help me I will be so happy.
Advertisement
Answer
For now I fix this problem with this:
JavaScript
ini_set("auto_detect_line_endings", true);
and this:
JavaScript
$got = fgets($fp, 120000);