【问题标题】:Reading from weight scale problems (PHP)阅读体重秤问题 (PHP)
【发布时间】:2017-01-24 19:23:39
【问题描述】:

我是 php 新手。目前我可以看代码(不好),可以写一点。

我有几个体重秤。 从第一个我可以用这个脚本读取重量:

    // 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);

这是套接字监听器的输出:

这是来自浏览器:

但从其他比例来看,我什么也看不懂。 这是socket终端的输出:(见图3)

我认为问题出在 php 脚本中,但我找不到。如果有人可以帮助我,我会很高兴。

【问题讨论】:

  • 现在我用这个来解决这个问题:` ini_set("auto_detect_line_endings", true); `

标签: php sockets


【解决方案1】:

现在我用这个来解决这个问题:

ini_set("auto_detect_line_endings", true);

还有这个:

$got = fgets($fp, 120000);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-02-25
    • 2017-05-27
    • 1970-01-01
    • 2015-08-15
    • 2011-08-13
    • 2021-09-20
    • 2021-10-04
    • 2018-09-21
    相关资源
    最近更新 更多