liderbug
03-07-2012, 11:24 PM
A minor modification to the http://smoothiecharts.org/ example.
line2.append(new Date().getTime(), Math.random());
becomes
line2.append(new Date().getTime(), updist());
var x = 0;
function updist()
{
x = ("<?PHP phpread() ?>");
return (x);
}
<?php
function phpread()
{
$t=$x=$y=$z=0;
$fd = fopen ("/tmp/seis", "r"); // /tmp/seis is a single line that changes 20/sec
$foo = fscanf ($fd, "%s", &$t);
fclose($fd);
$i = explode (",", $t);
echo "$i[2]"; // should go: 2 7 9 4 0 -1 -8 -4 -5 2....... instead I get 2 2 2 2 2 2 2 2
}
?>
----------------
So "line2.append..." calls updist which calls phpread which works fine - once. It's as if the phpread caches the results of the read and never rereads the file.
I'm snowed. :confused:
Thanks
Chuck
line2.append(new Date().getTime(), Math.random());
becomes
line2.append(new Date().getTime(), updist());
var x = 0;
function updist()
{
x = ("<?PHP phpread() ?>");
return (x);
}
<?php
function phpread()
{
$t=$x=$y=$z=0;
$fd = fopen ("/tmp/seis", "r"); // /tmp/seis is a single line that changes 20/sec
$foo = fscanf ($fd, "%s", &$t);
fclose($fd);
$i = explode (",", $t);
echo "$i[2]"; // should go: 2 7 9 4 0 -1 -8 -4 -5 2....... instead I get 2 2 2 2 2 2 2 2
}
?>
----------------
So "line2.append..." calls updist which calls phpread which works fine - once. It's as if the phpread caches the results of the read and never rereads the file.
I'm snowed. :confused:
Thanks
Chuck