Note that there are some explanatory texts on larger screens.

plurals
  1. PORead data from port get result fickle data
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/14032707/php-preg-match-to-get-a-word-after-space-which-is-where-it-a-word-kg">PHP preg_match to get a word after space, which is where it a word KG</a> </p> </blockquote> <p>I'm developing web application with PHP,My apps is communicate with scale digital, i'm using help with phpserial class. My problem is data is output in my browser mistmatch with output in scale digital. When in scale digital is <strong>16KG</strong>, so in browser output is <strong>NT,ST+16KG</strong> and then i refresh again the browser get other, like <strong>~!NT,ST+16KG, 16KG</strong>. My question, how to get data in browser just <strong>16KG</strong>.</p> <p>This is script to read data:</p> <pre><code>&lt;?php $serial = new phpSerial(); $serial-&gt;deviceSet("/dev/ttyUSB1"); $serial-&gt;confBaudRate(9600); //Baud rate: 9600 $serial-&gt;confParity("none"); //Parity (this is the "N" in "8-N-1") $serial-&gt;confCharacterLength(8); //Character length (this is the "8" in "8-N-1") $serial-&gt;confStopBits(1); //Stop bits (this is the "1" in "8-N-1") $serial-&gt;confFlowControl("none"); $serial-&gt;deviceOpen(); $serial-&gt;sendMessage(chr(1)); $tes = $serial-&gt;readPort(); print_r($tes); // get result ~!NT,ST+16KG, 16KG or NT,ST+16KG $serial-&gt;deviceClose(); ?&gt; </code></pre> <p>And this is code function readPort from class phpSerial.</p> <pre><code>function readPort ($count = 0) { if ($this-&gt;_dState !== SERIAL_DEVICE_OPENED) { trigger_error("Device must be opened to read it", E_USER_WARNING); return false; } $content = ""; $i = 0; if ($count !== 0) { do { if ($i &gt; $count) $content .= fread($this-&gt;_dHandle, ($count - $i)); else $content .= fread($this-&gt;_dHandle, 128); } while (($i += 128) === strlen($content)); } else { do { $content .= fread($this-&gt;_dHandle, 128); } while (($i += 128) === strlen($content)); } return $content; } </code></pre> <p>I'm developing use linux, port scale digital detect in /dev/ttyUSB1, i mean this problem is ASCII, so any help me with my problem. Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload